javascript - Angular ternary expression that runs more than one line of code -


so have example of code, in 1 of forms, works perfectly.

ng-submit="     commentctrl.edit(comment.id, comment.text);     comment.edit=false; " 

on other hand, when try run multiple "commands" in ternary ng-keyup, things go wrong, angular can't parse it.

ng-keyup=" ($event.keycode == 13 && !$event.shiftkey) ? commentctrl.edit(comment.id, comment.text);comment.edit=false : return" 

also tried:

($event.keycode == 13 && !$event.shiftkey) ? commentctrl.edit(comment.id, comment.text) && comment.edit=false : return" 

help me please!

it's bad practice write such expressions inside of markup.

anyway can putting values 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" 

Comments