gpt4 book ai didi

angularjs - Angular : ng-show and functions

转载 作者:行者123 更新时间:2023-12-04 15:31:03 25 4
gpt4 key购买 nike

假设你有一个像

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

我的问题是:函数什么时候运行?我如何告诉 angular 是时候重新运行该函数了?

最佳答案

嗯,ng-show 接受一个 bool 值,因此使用它的最佳选择是在设置 ng-show 的逻辑中的某处调用您的函数。

$scope.show = false;

$scope.showSomething = function(myCondition){
if(myCondition){
myFunction();
$scope.show = true;
}
};
<div ng-show='show'></div>

关于angularjs - Angular : ng-show and functions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43007568/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com