以下寫法:沒有明確指定module和controller,寫法不規範. 更改angular.js版本會出bug. 1 <html ng-app> 2 <head> 3 <title>1.0.1-1.5版本間的差異</title> 4 <script src="/js/angular-1.0.1.mi
以下寫法:沒有明確指定module和controller,寫法不規範. 更改angular.js版本會出bug.
1 <html ng-app> 2 <head> 3 <title>1.0.1-1.5版本間的差異</title> 4 <script src="/js/angular-1.0.1.min.js"></script> <!--可以正常顯示--> 5 <!--<script src="/js/angular.min.js"></script> 1.5版本 顯示不了--> 6 <script> 7 8 /* phones.js 9 [ 10 { 11 "name": "Nexus S", 12 "snippet": "Fast just got faster with Nexus S.", 13 "age": 0, 14 "imageUrl": "/img/01.png", 15 "id":1 16 }, 17 { 18 "name": "Motorola XOOM™ with Wi-Fi", 19 "snippet": "The Next, Next Generation tablet.", 20 "age": 1, 21 "imageUrl": "/img/02.png", 22 "id": 2 23 }, 24 { 25 "name": "MOTOROLA XOOM™", 26 "snippet": "The Next, Next Generation tablet.", 27 "age": 2, 28 "imageUrl": "/img/03.png", 29 "id": 3 30 } 31 ] 32 */ 33 function PhoneListCtrl($scope, $http) { 34 $http.get('/html/angular/json/phones.js').success(function (data) { 35 $scope.phones = data; 36 }); 37 } 38 </script> 39 <link href="/js/bootstrap-3.3.5-dist/css/bootstrap.min.css" rel="stylesheet" /> 40 </head> 41 <body > 42 <div class="container-fluid"> 43 <div class="row" ng-controller="PhoneListCtrl"> 44 45 <ul> 46 <li ng-repeat="phone in phones"> 47 <a href="#{{phone.id}}">{{phone.name}}</a> 48 <p>{{phone.snippet}}</p> 49 </li> 50 </ul> 51 52 53 </div> 54 </div> 55 </body> 56 </html>
附學習地址:
下篇:寫個規範的...