Ng-options按问题跟踪

ng-options track by issue

本文关键字:跟踪 问题 Ng-options      更新时间:2023-09-26

有一个选择下拉菜单

 <select ng-model="filter_cli" ng-options=" gc.id as gc.name for gc in
 businesses | filter :{type : 'CLIENT'} track by gc.id">

在应用程序中选择时,选择的值不会被显示,而是被分配。删除"track by"可以解决这个问题,但是选项的值需要是对象的id。

我想你只需要把你的track by移到你的过滤器之前:

<select ng-model="filter_cli" ng-options=" gc.id as gc.name for gc in
businesses track by gc.id | filter :{type : 'CLIENT'}">