且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

仅当变量设置为true时才调用函数

更新时间:2022-06-27 00:20:29

您可以像这样直接在点击处理程序中检查停止标记":

You can check the 'stop flag' directly in your click handler like this:

<div ng-click="stopmyFunc1 === undefined && myFunc1()">
    <!--some data here...-->
</div>

<button ng-click="stopmyFunc1 = true">Cancel</button>

因此,您无需在控制器中进行额外检查...

With that you don't need an additional check in your controller...