[英]load json object into ng-option in angular
<select ng-options="priority.level for priority in priority">
It return object object, what's wrong? 返回对象对象,怎么了? I also tried priority[0].level, it return blank.
我也尝试过priority [0] .level,它返回空白。
$scope.priority = [
{
"level":"High",
"index":1
},
{
"level":"Medium",
"index":2
},
{
"level":"Low",
"index":3
}
];
First of all why does your priority.level for priority in priority
not work? 首先,为什么您
priority.level for priority in priority
不起作用?
Counter question, would a loop like that work? 反问,这样的循环行得通吗?
var list = [1, 2, 3, 4, 5];
for(var i = 0; list < list.length; i++) {
list = list[i];
// do something with list...
}
That doesn't work obviously. 那显然行不通。 And you tried to do something similar.
您尝试做类似的事情。
To your sort question: You need to sort the list before you use the elements. 关于排序问题:在使用元素之前,需要对列表进行排序。
<ul>
<li ng-repeat="selected in priority | orderBy:'index'">{{selected.level}}</li>
</ul>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.