下面是我的JSON对象 Ctrlr.status 值
"[{\"Key\":\"8\",\"Value\":\"Auto\",\"Tid\":\"Date(-62135596800000)\",\"Uid\":null},{\"Key\":\"2\",\"Value\":\"Pending\",\"Tid\":\"Date(-62135596800000)\",\"Uid\":null},{\"Key\":\"4\",\"Value\":\"Resolution\",\"Tid\":\"Date(-62135596800000)\",\"Uid\":null},{\"Key\":\"6\",\"Value\":\"Resolve\",\"Tid\":\"Date(-62135596800000)\",\"Uid\":null}]"
我的下拉列表应包含值Auto,Pending,Resolution,Resolve。
下面是我的代码显示下拉列表
<select ng-model="gridCtrl.add.Rejection.status" ng-required="true"
options="s.value for s in Ctrlr.status"/>
但它显示空列表。请指出我的错误并告诉我如何填充这些值。提前致谢
答案 0 :(得分:0)
我首先将您的JSON数组分配给范围内的变量,如下所示:
$scope.statuses = [{\"Key\":\"8\",\"Value\":\"Auto\",\"Tid\":\"Date(-62135596800000)\",\"Uid\":null},{\"Key\":\"2\",\"Value\":\"Pending\",\"Tid\":\"Date(-62135596800000)\",\"Uid\":null},{\"Key\":\"4\",\"Value\":\"Resolution\",\"Tid\":\"Date(-62135596800000)\",\"Uid\":null},{\"Key\":\"6\",\"Value\":\"Resolve\",\"Tid\":\"Date(-62135596800000)\",\"Uid\":null}]
然后你可以用
循环它NG-选项
类似
ng-options="status.Key as status.Value for status in statuses"
见plunkr here