Is there any difference using ng-if with a value or with a function ?
ng-if=\"myvalue\"
ng-if=\"myfunc()\"
UPDATE (for a better understandi
For angular both are expression
, that it evaluates in context of current scope. Angular does this on each digest cycle.
There are more ways to shoot in the foot if you are using the function way. myfunc
could do
$scope.myfunc=function() {
//do some time consuming work
return data;
};
In such a case the binding evaluation on each digest cycle will make your binding and app slow.
So if you are using function based binding make sure that functions return fast by doing minimum processing.
Calling functions on ng-repeat directives can cause some performance issues, but if it's a one off evaluation then there isn't really a difference as far as I've noticed.
I always try to evaluate the property: ng-if="myValue"
would evaluate the scope variable $scope.myValue