Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJs ng-if function call from same controller not working

<div ng-repeat=" x in z"> 
    <div ng-if="function(x).y" >  
        display this
    </div>
</div>

In the above code, ng-if function(x) is not getting called without refresh.

Please check and suggest if I am missing any thing ?

like image 269
akmsharma Avatar asked Jan 14 '14 09:01

akmsharma


1 Answers

Here is working example

angular.module('app', [])
.controller('ctrl', function($scope) {
    $scope.z = [1,2,3];
    $scope.display = function(x) {
        return x === 2
    };
});

<div ng-app="app" ng-controller='ctrl'>
   <div ng-repeat=" x in z"> 
       <div ng-if="display(x)" >  
           display this
       </div>
   </div>
</div>

And fiddle.

like image 101
Andrew Shustariov Avatar answered Sep 28 '22 01:09

Andrew Shustariov