以下写法:没有明确指定module和controller,写法不规范. 更改angular.js版本会出bug.
<html ng-app>
<head>
<title>1.0.1-1.5版本间的差异</title>
<script src="/js/angular-1.0.1.min.js"></script> <!--可以正常显示-->
<!--<script src="/js/angular.min.js"></script> 1.5版本 显示不了-->
<script> /* phones.js
[
{
"name": "Nexus S",
"snippet": "Fast just got faster with Nexus S.",
"age": 0,
"imageUrl": "/img/01.png",
"id":1
},
{
"name": "Motorola XOOM™ with Wi-Fi",
"snippet": "The Next, Next Generation tablet.",
"age": 1,
"imageUrl": "/img/02.png",
"id": 2
},
{
"name": "MOTOROLA XOOM™",
"snippet": "The Next, Next Generation tablet.",
"age": 2,
"imageUrl": "/img/03.png",
"id": 3
}
]
*/
function PhoneListCtrl($scope, $http) {
$http.get('/html/angular/json/phones.js').success(function (data) {
$scope.phones = data;
});
}
</script>
<link href="/js/bootstrap-3.3.5-dist/css/bootstrap.min.css" rel="stylesheet" />
</head>
<body >
<div class="container-fluid">
<div class="row" ng-controller="PhoneListCtrl"> <ul>
<li ng-repeat="phone in phones">
<a href="#{{phone.id}}">{{phone.name}}</a>
<p>{{phone.snippet}}</p>
</li>
</ul> </div>
</div>
</body>
</html>
附学习地址:
下篇:写个规范的...