angularjs的问题 用ng-repeat读不出数据
<htmlng-app><head><metacharset="utf-8"/><scriptsrc="http://apps.bdimg.com/libs/angula...
<html ng-app>
<head>
<meta charset="utf-8"/>
<script src="http://apps.bdimg.com/libs/angular.js/1.3.9/angular.min.js"></script>
<script src="itemlist.js"></script>
</head>
<body ng-controller="PhoneListCtrl">
<ul>
<li ng-repeat="phone in phones">
<p>{{phone.name}}</p>
<p>{{phone.snippet}}</p>
</li>
</ul>
</body>
</html>
打开网页一片空白
function PhoneListCtrl($scope) {
$scope.phones = [
{"name": "Nexus S",
"snippet": "Fast just got faster with Nexus S."},
{"name": "Motorola XOOM™ with Wi-Fi",
"snippet": "The Next, Next Generation tablet."},
{"name": "MOTOROLA XOOM™",
"snippet": "The Next, Next Generation tablet."}
];
} 展开
<head>
<meta charset="utf-8"/>
<script src="http://apps.bdimg.com/libs/angular.js/1.3.9/angular.min.js"></script>
<script src="itemlist.js"></script>
</head>
<body ng-controller="PhoneListCtrl">
<ul>
<li ng-repeat="phone in phones">
<p>{{phone.name}}</p>
<p>{{phone.snippet}}</p>
</li>
</ul>
</body>
</html>
打开网页一片空白
function PhoneListCtrl($scope) {
$scope.phones = [
{"name": "Nexus S",
"snippet": "Fast just got faster with Nexus S."},
{"name": "Motorola XOOM™ with Wi-Fi",
"snippet": "The Next, Next Generation tablet."},
{"name": "MOTOROLA XOOM™",
"snippet": "The Next, Next Generation tablet."}
];
} 展开
展开全部
换成 http://www.apjs.net/ 中文官网的angular之后可以运行起来,不知道是不是你的js有问题,或者是版本问题。
<script src="http://code.angularjs.org/angular-1.0.1.min.js"></script>
<script src="http://code.angularjs.org/angular-1.0.1.min.js"></script>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
改动地方1:
<html ng-app="app">
改动地方2:在script中加上下面几句
var app=angular.module("app",[]);
app.controller("PhoneListCtrl",PhoneListCtrl);
<html ng-app="app">
改动地方2:在script中加上下面几句
var app=angular.module("app",[]);
app.controller("PhoneListCtrl",PhoneListCtrl);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
ng-controller="PhoneListCtrl" 这个属性不要放在 <body> 里 给body 内加个DIV 把需要实现的内容都放在此DIV内即可
<body>
<div ng-controller="PhoneListCtrl">
<ul>
<li ng-repeat="phone in phones">
<p>{{phone.name}}</p>
<p>{{phone.snippet}}</p>
</li>
</ul>
</div>
</body>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询