[英]AngularJS ng-repeat not working with select options
我已將數組分配給名為的對象
processMapAttrib.auditNotifyUsers.unAssignedUsers
當我使用以下命令在HTML文件中打印變量時
<label>{{processMapAttrib.auditNotifyUsers.unAssignedUsers}}</label>
我懂了
[{"id":230,"name":"Parthiban V"},{"id":231,"name":"Kanna A"},{"id":252,"name":"jagadesh S"},{"id":253,"name":"saravana kumar"},{"id":346,"name":"sith user"},{"id":347,"name":"seventh user"},{"id":348,"name":"unlimited user"}]
processMapAttrib也具有其他值。 說像processMapAttrib.Process = {},processMapAttrib.task = {},......
但是當我在ng-repeat中使用它時它不起作用。
<select multiple="multiple">
<option value="{{list.id}}" ng-repeat="list in processMapAttrib.auditNotifyUsers.unAssignedUsers">{{list.name}}</option>
</select>
請幫助我將數據填充到選擇選項中。
最后,我在代碼中找到了問題。 我已將value屬性更改為ng-value。 而且工作正常。
<option ng-value="list.id" ng-repeat="list in processMapAttrib.auditNotifyUsers.unAssignedUsers">{{list.name}}</option>
試試這個代碼:
var app = angular.module("myApp", []) app.controller("myCtrl", function ($scope) { $scope.processMapAttrib = [{ "id": 230, "name": "Parthiban V" }, { "id": 231, "name": "Kanna A" }, { "id": 252, "name": "jagadesh S" }, { "id": 253, "name": "saravana kumar" }, { "id": 346, "name": "sith user" }, { "id": 347, "name": "seventh user" }, { "id": 348, "name": "unlimited user" }] });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app="myApp" ng-controller="myCtrl"> <label>{{processMapAttrib}}</label> <select multiple="multiple"> <option value="{{list.id}}" ng-repeat="list in processMapAttrib">{{list.name}}</option> </select> </div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.