UI 选择未按预期绑定值



将此选择框转换为多选框时出现问题。

 <select  style="width: 100%;" ng-model="vaccjobctrl.vacc.vaccination" 
                                     ng-options="vacctype.vaccinationId as vacctype.vaccinationName for vacctype in vaccjobctrl.vaccinationMast"
                                     class="form-control field-size ng-pristine ng-invalid ng-invalid-required ng-valid-maxlength ng-touched" name="vaccinationName"
                                     id="vaccinationName" required >
                                     <option value="">--SELECT--</option>
                                     <option value="{{vacctype.vaccinationId}}">{{vacctype.vaccinationName}}</option>
                         </select>

尝试将其转换为多选 ui,但它没有按预期返回

<ui-select tagging="tagTransform" ng-model="vm.user.instId" theme="bootstrap"  id="institute" name="institute"  append-to-body="false" ng-required="true">
                            <ui-select-match placeholder="Select Vaccination..."> <span
                                ng-bind="$select.selected.vaccinationName"></span> 
                            </ui-select-match> 
                                <ui-select-choices repeat="vaccine in (vaccjobctrl.vaccinationMast | filter: $select.search) track by vaccine.vaccinationId">
                            <span ng-bind="item.vaccinationName"></span> 
                            <!-- <div ng-bind-html="item.instName | highlight: $select.search"></div> --></ui-select-choices> </ui-select> 

这是存储在 vaccjobctrl.vaccinationMast 中的 json。

{
  "code": 0,
  "message": "Total 6 records found",
  "result": [
    {
      "vaccinationId": 1,
      "vaccinationName": "vacc 1",
      "vaccinationNameAr": null
    },
    {
      "vaccinationId": 2,
      "vaccinationName": "vacc 2",
      "vaccinationNameAr": null
    },
    {
      "vaccinationId": 3,
      "vaccinationName": "vacc 3",
      "vaccinationNameAr": null
    },
    {
      "vaccinationId": 4,
      "vaccinationName": "vacc 4",
      "vaccinationNameAr": null
    },
    {
      "vaccinationId": 5,
      "vaccinationName": "vacc 5",
      "vaccinationNameAr": null
    },
    {
      "vaccinationId": 6,
      "vaccinationName": "vacc 6",
      "vaccinationNameAr": null
    }
  ]
}

小提琴 http://jsfiddle.net/uhgvLjgp/44/

您没有在ng-options中访问json中的结果数组

 ng-options="vacctype.vaccinationId as vacctype.vaccinationName for vacctype in vaccjobctrl.vaccinationMast.result"

相关内容

  • 没有找到相关文章

最新更新