是否可以在2个条件为真时调用函数?
<a id="Send" ng-click="(model.condition1 and model.condition2) || doSomething()"></a>
答案 0 :(得分:3)
处理实际功能:
ng-click="doSomething()"
$scope.doSomething = function() {
if (!model.condition1 and model.condition2)
return
//do stuff
}
答案 1 :(得分:2)
理想情况下,您应该保持逻辑远离template
。但这应该有效:
<a id="Send"
ng-click="model.condition1 && model.condition2 && doSomething()"></a>
示例强>:
<form name="myForm" ng-controller="Ctrl">
userType: <input name="input" ng-model="userType" required>
<a id="Send"
ng-click="myForm.$valid && userType.length() > 2 && doSomething()"></a>
</form>