Reputation:
Is is possible to have something like:
<div ng-click="someVar == '1' ? functionOne() : functionTwo() ">
Click me!
</div>
So depending what someVar
is, ng-click
would either run functionOne
or functionTwo
.
Upvotes: 0
Views: 3963
Reputation: 832
yes, you can do it.
<div ng-click="obj.length>1 ? functionOne() : functionTwo() ">
Click me!
</div>
Upvotes: 0
Reputation: 23300
I suggest creating "handlers" for this:
<div ng-click="functionThree(someVar)">
Click me!
</div>
function functionThree(someVar){
someVar == '1' ? functionOne() : functionTwo();
}
Upvotes: 3