Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular: ng-show and functions

Tags:

angularjs

Say you have a template like

<a ng-show=function()>a link</a>

My question is: when is function run? How can I tell angular that it is time to re-run the function?

like image 955
josinalvo Avatar asked Mar 24 '17 19:03

josinalvo


1 Answers

Well, ng-show takes a Boolean value, so your best option for using it is to call your function somewhere in the logic that sets ng-show.

$scope.show = false;

$scope.showSomething = function(myCondition){
    if(myCondition){
        myFunction();
        $scope.show = true;
    }
};
<div ng-show='show'></div>
like image 64
samnu pel Avatar answered Oct 12 '22 15:10

samnu pel