Angularjs--ajax
1<! DOCTYPE html>234<meta charset= "UTF-8" >5<meta name= "viewport" content= "Width=device-width, initial-scale=1, maximum-scale=1, User-scalable=no" >6<title>index</title>7<link href= "{$Think. Const. Cssurl}bootstrap.min.css "rel=" stylesheet "type=" Text/css "/>8<script src= "{$Think. Const. Js}jquery.min.js "type=" Text/javascript "></script>9<script src= "{$Think. Const. Js}bootstrap.min.js "type=" Text/javascript "></script>Ten<script src= "{$Think. Const. Js}angular.min.js "type=" Text/javascript "></script> One<link href= "{$Think. Const. Cssurl}home/index.css "rel=" stylesheet "type=" Text/css "/> A -<body ng-app= "MyApp" ng-controller= "Myctrl" > -<divclass= "Container" > theclass= "Page-header" > Front-end technology - -<tableclass= "Table table-striped table-bordered table-hover" > -<tr> +<th>id</th> -<th>name</th> +<th>city</th> A<th>price</th> at<th> Number</th> -<th>picture</th> -</tr> -<TR ng-repeat= "Item in Items" > -<td>{{item.id}}</td> -<td>{{item.name}}</td> in<td>{{item.city}}</td> -<td>{{item.price}}</td> to<td>{{item. Number}}</td> +<td>{{item.picture}}</td> -</tr> the</table> * $$Think. Const. Homeimg}/01.png "/>Panax Notoginseng</div> -</body> the<script> +App = Angular.module ("MyApp",[]); AApp.controller ("Myctrl",function($scope,$http){ the $http. Post ("Http://localhost/tkphp/index.php/home/index/data"). Success (function(res) { + $scope. Items =Res; - }) $ }); $</script> - - the<?PHP - namespace Home\controller;Wuyi UseThink\controller; the classIndexcontrollerextendsController { - Wu Public functiondata () { - $model= M ("NewItems"); About $data=$model-Select (); $ $this->ajaxreturn ($data); - } - - } A?> + the /* - Output JSON $ the [{' id ': ' 1 ', ' name ': ' \u6c83\u7279\u7bee\u7403\u978b ', ' City ': ' \u4f5b\u5c71 ', ' price ': ' + ', ' number ': ' $ ', ' picture ":" 001.jpg "},{" id ":" 2 "," Name ":" \u5b89\u8e0f\u8fd0\u52a8\u978b "," City ":" \u798f\u5dde "," Price ":" + "," Number ":" "," "Picture": "002.jpg"},{"id": "3", "Name": "\u8010\u514b\u8fd0\u52a8\u978b", "City": "\u5e7f\u5dde", "Price": "500 "," number ":" 003.jpg "},{" id ":" 4 "," Name ":" \u963f\u8fea\u8fbe\u65aft\u8840\u886b "," City ":" \u4e0a \u6d77 "," Price ":" 388 "," Number ":" $ "," picture ":" 004.jpg "},{" id ":" 5 "," Name ":" \u674e\u5b81\u6587\u5316\u886b "," City ":" \u5e7f\u5dde "," Price ":" + "," number ":" $ "," picture ":" 005.jpg "},{" id ":" 6 "," Name ":" \u5c0f\u7c733 "," City " : "\u5317\u4eac", "Price": "1999", "Number": "The", "Picture": "006.jpg"},{"id": "7", "Name": "\u5c0f\u7c732s", "City": " \u5317\u4eac "," Price ":" 1299 "," Number ":" $ "," picture ":" 007.jpg "},{" id ":" 8 "," Name ":" thinkpad\u7b14\u8bb0\u672c "City": "\u5317\u4eac", "Price": "6999", "Number": "$", "picture": "008.jpg"},{"id": "9", "Name": "Dell\u7b14\u8bb0\ U672c "," City":" \u5317\u4eac "," Price ":" 3999 "," Number ":" $ "," picture ":" 009.jpg "},{" id ":" Ten "," Name ":" Ipad5 "," City ":" \u5317\ U4eac "," Price ":" 5999 "," Number ":" $ "," picture ":" 010.jpg "}] the */
Angularjs--ajax