Javascript 从另一个ng重复列表中筛选ng重复列表的元素
我只有一个显示标题、说明和类别的数组。Javascript 从另一个ng重复列表中筛选ng重复列表的元素,javascript,angularjs,angularjs-ng-repeat,angularjs-filter,Javascript,Angularjs,Angularjs Ng Repeat,Angularjs Filter,我只有一个显示标题、说明和类别的数组。 由于我不知道类别(因为用户可以添加他们自己的类别),我使用ng REPECT创建了类别列表,以显示项目。 我需要项目能够使用两个过滤器进行过滤:使用文本输入,按标题进行过滤(这一个非常好用),以及使用类别按钮(不起作用) 以下是我如何为类别重复ng的步骤: <div class="list_categories"> <!-- I put 'ng-repeat-start' and 'ng-repeat-end' to
由于我不知道类别(因为用户可以添加他们自己的类别),我使用ng REPECT创建了类别列表,以显示项目。
我需要项目能够使用两个过滤器进行过滤:使用文本输入,按标题进行过滤(这一个非常好用),以及使用类别按钮(不起作用) 以下是我如何为类别重复ng的步骤:
<div class="list_categories">
<!-- I put 'ng-repeat-start' and 'ng-repeat-end' to be able to add the value "checked" to the first input -->
<!-- it wasn't working and @tbone849 already helped me with that-->
<label ng-click="clearAll()" ng-repeat-start="x in categories" ng-if="$first">
<input type="radio" id="optradio" name="optradio" ng-model="searchCategory.Category" value="{{x}}" checked="checked">
<p>{{x}}</p>
</label>
<label ng-click="clearAll()" ng-repeat-end ng-if="!$first">
<input type="radio" id="optradio" name="optradio" ng-model="searchCategory.Category" value="{{x}}">
<p>{{x}}</p>
</label>
</div>
{{x}
{{x}
以下是重复的项目:
<div class="card" ng-repeat="x in items | filter:searcher | filter:searchCategory" >
<div class="title-space">
<h2>{{x.Title}}</h2>
</div>
<div class="description-space">
<p>{{x.Description}}</p>
</div>
</div>
{{x.Title}}
{{x.Description}}
有关我的代码的更多详细信息,我在中做了一个工作示例。我希望有人能帮助我使类别过滤器正常工作。使用ng checked处理第一个选项的检查
<label ng-click="clearAll()" ng-repeat="x in categories">
<input type="radio" id="optradio" ng-model="searchCategory.Category" name="optradio" ng-value="{{x}}" ng-checked="$first">
<p>{{x}}</p>
</label>
{{x}
谢谢,这真的很有效。。我的主要问题是过滤问题。他们能按一个类别或多个类别进行搜索吗?检查Plunker示例,我用类别创建了一个数组,并用它创建了de categories列表。尝试将过滤参数更改为searchCategory。Categori我想已经是这样了,无线电输入有ng model=“searchCategory.category”