Skip to content Skip to sidebar Skip to footer

Angular Ternary Expression That Runs More Than One Line Of Code

so I have this example of code, in one of my forms, it works perfectly. ng-submit=' commentCtrl.edit(comment.id, comment.text); comment.edit=false; ' on the other hand, wh

Solution 1:

It's a bad practice to write such expressions inside of markup.

Anyway you can do it by putting the values into an array:

ng-submit="[commentCtrl.edit(comment.id, comment.text), comment.edit=false]"

ng-keyup="($event.keyCode == 13 && !$event.shiftKey)
? [commentCtrl.edit(comment.id, comment.text), comment.edit=false]
: 0"

Post a Comment for "Angular Ternary Expression That Runs More Than One Line Of Code"