![](/img/trans.png)
[英]How to select dropdownlist values of particular text value which is in ng-repeat and ng-model in angularjs and how can we post it to database
[英]How to filter ng-repeat values based on another input ng-model value in angularjs?
重復基於angularjs中另一個輸入ng-model值的值?
我有一個輸入值,例如Social Psychology
因為這個值ng-model is kpcategory
我在問題中使用了像ng-repeat="question in questions
這樣的ng-repeat="question in questions
來列出所有category
和name
。
ng-repeat
列表中的Social Psychology
類別,所以我使用了ng-repeat="question in questions | filter:kpcategory"
。 Social Psychology
數據。 但我只想過濾Social Psychology
的類別值,而不是所有數據的類別值。 問題是它被過濾,包括category and category_two
數據。 預期結果是:
只是想按catgory
Social Psychology
進行篩選,因此結果應為Social Psychology , John
。
我們沒有解決該問題的方法,請幫助我們。
您可以嘗試以下按照類別屬性過濾項目
<div ng-repeat="question in questions | filter:{ category: kpcategory }">
<ul>
<li><span>{{question.category}} , {{question.name}}</span></li>
</ul>
</div>
嘗試做這個演示
<input type="text" name="kpcategory"
data-ng-model="kpcategory.category" value="kpcategory">
<div ng-repeat="question in questions | filter:kpcategory ">
<ul>
<li><span>{{question.category}} , {{question.name}}</span></li>
</ul>
注意 :我在輸入字段中輸入了data-ng-model="kpcategory.category"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.