gpt4 book ai didi

javascript - ng-click 目录中使用三元运算符的多个函数

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

是否可以在 ng-click 目录中使用三元运算符并调用多个函数?我的意思是这样的:

<div ng-click="a==1 ? func1() func2() : ''">

最佳答案

是的,但是请参阅三元运算符,如 link说:

You can also do more than one single operation per case, separatingthem with a comma, and enclosing them in parenthesis:

var stop = false, age = 23;

age > 18 ? (
alert('OK, you can go.'),
location.assign('continue.html') ) : (
stop = true,
alert('Sorry, you are much too young!') );

You can also do more than one operation during the assignation of avalue. In this case, the last comma-separated value of the parenthesiswill be the value to be assigned.

但是,这对你来说不是问题。

关于javascript - ng-click 目录中使用三元运算符的多个函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46384287/

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