$ parse:在ui select repeat中使用{{variable}}时出现语法错误

时间:2016-09-21 09:42:42

标签: angularjs ui-select

我正在使用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有增量号。

1 个答案:

答案 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]"