Angular
语法
/*循环用法,变量引用*/
<li ng-repeat="phone in phones">
<span>{{phone.name}}</span>
<p>{{phone.snippet}}</p>
</li>
控制器
//控制器绑定
<body ng-controller="PhoneListController">
...
</body>
//控制器的使用
// 声明根模块
angular.module('phonecatApp', []);
// 使用HTML声明好的模块,利用$scope来引用、赋值变量
phonecatApp.controller('PhoneListController', function PhoneListController($scope) {
$scope.phones=[...];
...
http请求
function PhoneListController([$scope,] $http,[$routeParams]) {
$http.get('phones/phones.json').then(function(response) {
self.phones = response.data;
});
...
}