Is it possible to call a method only when a condition in ng-if is true? I have a repeat like this
<div ng-repeat="i in items" ng-if="i.loc == 'abc'">
<h1>Hello.. {{getName()}}</h1>
</div>
here is the js code
$scope.getName = function() {
console.log('fired');
return "myName";
}
From console I can see that this method is firing many more times then items.length and i.loc condition. So how to call this inside method only when ng-if is true