Join the Stack Overflow Community
Stack Overflow is a community of 6.5 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up
<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 ?

share|improve this question
1  
Can you please provide more code (the whole ng-app and controller). Also mind that anything in a directive is not strictly JavaScript, it's an angular expression. – Yoeri Jan 14 '14 at 9:56
up vote 9 down vote accepted

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.

share|improve this answer
    
I am doing exactly like this and during first call, display function does get called but after ward, once I come from some other route url, display is not called again. Any suggestions on that ? – akmsharma Jan 14 '14 at 10:46
    
Thank, I had another flag value that need to be checked. Working fine now. – akmsharma Jan 14 '14 at 10:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.