Ng-If-6

 

In this example there is an array named Arrs which contains four elements but show only two element because ng-if directive evaluates expression i.e Arr will not contain element One and Four.It will show element Two and Three.

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="initExample"> <div ng-controller="ExampleController as vm"> <div ng-repeat="Arr in Arrs"> <span ng-if="Arr!='One' && Arr!='Four'">{{Arr}}</span> </div> </div> <script> var app = angular.module("initExample", []); app.controller('ExampleController', ['$scope', function ($scope) { $scope.Arrs = ["One", "Two","Three","Four"] }]); </script> </body> </html>
Output