angular.js demo
<!DOCTYPE html> <html> <head> <title></title> <script type="text/javascript" src="angular.min.js"></script> <script type="text/javascript"> var app = angular.module("test",[]); app.controller("zhangshan",function ($scope,$http) { $scope.list = []; $scope.alert= function(ddd){ alert(ddd); $http.get("/one.php") .then(function (ret){ $scope.list = ret.data; angular.forEach($scope.list,function(value,key){ alert(key+">>>"+value); if(key=="ddd") {$scope.list[key]["class"]="fuck"} }); }) } $scope.bbb = "aaaaaaaaaaaaaaaaaaaaa"; }) </script> </head> <body ng-app="test"> <input ng-model="aaa"> <div >{{aaa}}</div> <div ng-controller="zhangshan">{{bbb}} <input ng-model="str"/> <button ng-click="alert(str)">click</button> {{list}} <ul> <li ng-repeat="(ccc,li) in list" class="1{{li['class']}}1">{{ccc}}---{{li}}</li> </ul> </div> </body> </html>
<?php $aaa["rrr"] = "aa9999999999999999999999999999999999999999999999999999999999999998a"; $aaa["ddd"] = "bbb"; echo json_encode($aaa);