作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
嗨,我正在尝试使用 ng-repeat 迭代 json 对象,当我迭代数组时,它工作正常,但使用 json 对象时,它失败了。
这是我的 JavaScript 代码:
var appModule = angular.module('appModule',[]);
appModule.controller('appController',[function(){
this.students = {
"abc":"abc",
"xyz":"xyz",
"xyz":"xyz"
}
}]);
这是我的 html 代码:
<!DOCTYPE html>
<html ng-app="appModule">
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.js"></script>
</head>
<body ng-controller="appController as controller">
<div ng-repeat="(firstName,lastName)in controller.students">
<span>Name:{{firstName}} Surname: {{lastName}}</span>
</div>
<script type="text/javascript" src="./app.js"></script>
</body>
</html>
最佳答案
可以尝试这样显示数据
<body ng-controller="appController as controller">
<div ng-repeat="student in controller.students">
<span>Name:{{student.firstName}} Surname: {{student.lastName}}</span>
</div>
</body>
关于javascript - 错误: [ngRepeat:iexp] Expected expression in form of '_item_ in _collection_[ track by _id_]' but got '(name,surname)in controller.students' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39796854/
我正在尝试下面的代码 element.append('{{feat.Name}} None {{x.value}}'); 低于错误 Error: [ngRepeat:iidexp] 'item' in
使用 ng-repeat 时仅获取第一个元素作为输出并在控制台中出现错误: Expected expression in form of '_item_ in _collection_[ track
嗨,我正在尝试使用 ng-repeat 迭代 json 对象,当我迭代数组时,它工作正常,但使用 json 对象时,它失败了。 这是我的 JavaScript 代码: var appModule =
我正在尝试创建一个 ionic 移动应用程序,因为我在 ng-repeat 中遇到错误,错误是 ionic.bundle.js:25642 Error: [ngRepeat:iexp] Expecte
我是一名优秀的程序员,十分优秀!