简体   繁体   中英

How to call multiple functions in ng-keyup?

Edit: This is the crux of what I'm asking.

Here's my html code:

<input id="newTagInput" ng-keyup="$event.keyCode === 13 && vm.addTag() ; vm.toggleClick()">

When the user presses enter (keycode = 13) , I need to perform vm.addTag() and vm.toggleClick(). How do I do this? What is wrong with the syntax? I do not really understand the angular documentation on this.

To call multiple functions in an ng-keyup, you can wrap your desired functions in a comma separated array. Like so:

<input id="newTagInput" ng-keyup="$event.keyCode === 13 && [vm.addTag(), vm.toggleClick()]">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM