我正在使用WebStorm JetBrains学习AngularJS,我有这个非常示例的应用程序,但是当我按下Debug按钮时,它没有在页面中显示数组(它在Chrome中打开了一个网页:
http://localhost:63342/example/index.html
我正在使用适用于Chrome的插件连接器,我在Chrome控制台中没有错误。
我的错误在哪里? Link to Fiddle
HTML(index.html)
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body ng-app="webStorm" ng-controller="webStormController as ws">
<div ng-repeat="person in ws" ng-click="ws.showPerson(person)">
{{person.firstName}}
</div>
<script type="text/javascript" src="bower_components/angular/angular.min.js"></script>
<script type="text/javascript" src="app.js"></script>
</body>
</html>
JS(app.js)
var webStorm = angular.module("webStorm", []);
webStorm.controller("webStormController", function(){
var ws = this;
ws.people = [{firstName: "John", lastName: "Smith"}];
console.log(ws.people);
ws.showPerson = function (person) {
console.log(person);
}
})
谢谢!
答案 0 :(得分:2)
<div ng-repeat="person in ws.people" ng-click="ws.showPerson(person)">
{{person.firstName}}
</div>
按person in ws
person in ws.people
答案 1 :(得分:1)
我认为你的意思是:ng-repeat="person in ws.people"
,这就是你要迭代的数组:)