Javascript 所选选项的筛选
如何根据所选选项筛选表内容?Javascript 所选选项的筛选,javascript,angularjs,select,Javascript,Angularjs,Select,如何根据所选选项筛选表内容? 我需要刷新下表-每次select上的选项更改时 HTML <select ng-model="selectedGrade" ng-options="grade.Id as grade.Title for grade in grades"></select> <table> <tr> <th>ID</th> <th>Description</th> &l
我需要刷新下表-每次select上的选项更改时 HTML
<select ng-model="selectedGrade" ng-options="grade.Id as grade.Title for grade in grades"></select>
<table>
<tr>
<th>ID</th>
<th>Description</th>
</tr>
<tr ng-repeat="attr in attributes|filter:{grade:selectedGrade.Title}">
<td>{{attr.id}}</td>
<td>{{attr.name}}</td>
</tr>
</table>
将
{{selectedGrade}}
添加到模板中。您会注意到,selectedGrade
包含的是所选等级的ID,因为您使用了
grade.Id as grade.Title for grade in grades
如果希望selectedGrade
包含坡度对象,应使用
grade.Title for grade in grades
阅读。您的对象不包含任何
grade
属性,您正在对grade属性进行筛选。属性确实包含grade属性。哦,对不起,我误读了代码。
grade.Title for grade in grades