Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/420.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 所选选项的筛选_Javascript_Angularjs_Select - Fatal编程技术网

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