码迷,mamicode.com
首页 > Web开发 > 详细

angular.js写法不规范导致错误

时间:2016-02-22 20:52:58      阅读:284      评论:0      收藏:0      [点我收藏+]

标签:

以下写法:没有明确指定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>

 

附学习地址:

a.angularJS中文社区

b.angularJS官网

 

下篇:写个规范的...

angular.js写法不规范导致错误

标签:

原文地址:http://www.cnblogs.com/DKnight/p/5208064.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!