Search code examples
angularjsangularjs-ng-repeatangularjs-ng-if

angularjs ng-repeat inside ng-if


angular js ng-if inside ng-repeat not working My angularjs ng-if code

<div ng-controller="Ctrl">
   <div ng-repeat = "data in categories">
     <div ng-if="data.name == 'Sport' ">
          {{data.name}}
     </div> 
 </div>
</div> 

Solution

  • In your fiddle you're using AngularJS 1.0.6. ng-if was introduced from 1.1.5. Change AngularJS version and your code will work.

    http://jsfiddle.net/PQvQ2/760/

    If you really need 1.0.6 (not suggested at all) you can change ng-if to ng-show. It will hide the other elements, but I repeat, I don't suggest it. Please upgrade to a newer AngularJS version.