Chris
Chris

Reputation: 179

Angular switch from ng-show to ng-repeat filter / how to

What is the correct syntax to switch from my simple ng-show to a filter in my ng-repeat? (item in list | filter:{item.value == 'abc'} or so)

<ol ng-repeat="item in list">
    <li ng-show="item.value == 'abc'">test</li>
</ol>

Upvotes: 0

Views: 71

Answers (4)

gaurav bhavsar
gaurav bhavsar

Reputation: 2043

Do not use ng-repeat inside <ol> tag.

This will repeat <ol> tag each time with single <li>.

Use ng-repeat in <li> tag to repeat <li> tag inside <ol> tag and use filter with ng-repeat.

use like this :

<ol>
  <li ng-repeat="item in list | filter: { value : 'abc' }">test</li>
</ol>

working plunkr

Upvotes: 1

Dongkwon Lee
Dongkwon Lee

Reputation: 213

You can use nf-repeat Filter

<ol ng-repeat="item in list | filter : {value : 'abc'}">
<li>test</li>
</ol>

read AngularJS API Document

Upvotes: 0

SiCK
SiCK

Reputation: 367

Try this

<ol ng-repeat="item in list | filter: {value: 'abc'}">
    <li>test</li>
</ol>

Angular Filter doc

Upvotes: 0

henrikmerlander
henrikmerlander

Reputation: 1574

<ol ng-repeat="item in list | filter:{value: 'abc'}">
    <li>test</li>
</ol>

Plunker: https://plnkr.co/edit/uw0LNygWbj4Njhp1n7PN?p=preview

Upvotes: 0

Related Questions