我正在使用angular.js:13920错误:[$ parse:syntax]当我在重复ui-select-choices时使用带有字符串的{{variable_name}}。
<ui-select ng-model="dfaDetail.location.selected" theme="bootstrap" style="width:300px;">
<ui-select-match placeholder="Select or search Location...">{{$select.selected.locationCode}}</ui-select-match>
<ui-select-choices repeat="item in locData{{myindex}} | filter: $select.search">
<div ng-bind-html="item.locationCode | highlight: $select.search"></div>
<small ng-bind-html="item.locationId | highlight: $select.search"></small>
</ui-select-choices>
</ui-select>
我已经使用字符串连接与变量类似于上面的选择ng-options重复如下,但是为了能够我得到错误。
<select data-live-search="true" data-size="15" data-container="body" title="Location Name:" name="choose_loc" ng-model = "dfaDetails.locationName"
ng-options="p.locationId as p.locationCode for p in locData{{myno}}">
<option class="small-font" value="">Select Location </option>
</select>
有什么方法可以使用带有重复的动态变量。 用例:对于每一行,我会有一个新的变量,如locData1,locData2 ..所以我想使用locData {{myno}},其中myno有增量号。
答案 0 :(得分:0)
你应该在ng-repeat {{}}
locData [myindex]`
. Basically you wanted to access object via its key, so you could do it like this
插值指令
<ui-select-choices repeat="item in locData[myindex] | filter: $select.search">
在ng-options
ng-options="p.locationId as p.locationCode for p in locData[myno]"