Displaying JSON Data in AngularJS in array

310
April 26, 2017, at 5:01 PM

I'm new to angularjs. I'm trying to display data from a php controller returned to server. I'm fetching that data in angular but there is a problem since data is not getting displayed. my code is attached. Controller Action Method

public function actionAhmed(){
$unit = Units::model()->findAll();
$unitList = array();
foreach($unit as $value){
$unitList[] = $value->attributes;
}
return json_encode($unitList);  
}

Angular Controller

    var myModel = angular.module('MyModel', []);
    app.controller('myCtrl', function($scope, $http) {
    $http.get('http://localhost/tutorial/index.php/units/ahmed')
    .then(function (response) {
        $scope.parsedData = response.data;
});    
});

HTML code

<div ng-app="MyModel" ng-controller="myCtrl">
<ul>
    <li ng-repeat="x in parsedData">
        {{ x.Name + ', ' + x.Country }}
    </li>
</ul>
</div>
Rent Charter Buses Company
READ ALSO
PHP PDO union select getting fatal error

PHP PDO union select getting fatal error

This is my query in mssql using php pdo and I am getting this :

474
Invalid year/week combination in PHP on first days of the year

Invalid year/week combination in PHP on first days of the year

Why does this happen (might be cause Carbon extends DateTime and this http://phpnet/manual/es/datetime

274
Radio inputs in a List.js fuzzy-search not making it to POST

Radio inputs in a List.js fuzzy-search not making it to POST

I have a form that allows people to fill out a 'duty roster', selecting a person from a list who is responsible for a particular taskI am using List

307