admin管理员组文章数量:1425717
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.
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.
Share Improve this question edited Jun 13, 2016 at 14:29 McFiddlyWiddly asked Jun 13, 2016 at 1:02 McFiddlyWiddlyMcFiddlyWiddly 58110 silver badges32 bronze badges 5- 1 Why not just have a single wrapper function in place of vm.toggleClick(), that calls toggleClick() and whatever other functions you need to call. – ruby_newbie Commented Jun 13, 2016 at 1:05
-
From objective description I don't even see what you need
ng-keyup
for. Also you havevm.newTag
as both a model and a function..... can't be both – charlietfl Commented Jun 13, 2016 at 1:13 - ToggleClick() does something really simple, basically does this.clicked = !this.clicked. If that helps solve the particular problem. But I'm also looking for a general answer to the question, so that I can learn. – McFiddlyWiddly Commented Jun 13, 2016 at 1:27
- The post is rather unclear. It would help if you extend the code the bit into an minimal reproducible example. Apart from a repro, some things in your text and question title are unclear too: you mix talking about clicks and key-up events. It's also a bit unclear why the question title subtly but importantly differs from the one-line question in the post body ("functions" vs "events"). Please review the post and edit to clarify. – Jeroen Commented Jun 13, 2016 at 5:42
- @ruby_newbie Your solution works, but I was looking for a general answer to how to call multiple functions with ng-keyup, or if it was possible to do so. – McFiddlyWiddly Commented Jun 13, 2016 at 16:29
1 Answer
Reset to default 6To call multiple functions in an ng-keyup, you can wrap your desired functions in a ma separated array. Like so:
<input id="newTagInput" ng-keyup="$event.keyCode === 13 && [vm.addTag(), vm.toggleClick()]">
本文标签: javascriptHow to call multiple functions in ngkeyupStack Overflow
版权声明:本文标题:javascript - How to call multiple functions in ng-keyup? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745418513a2657797.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论