如何使用多前pressions NG-点击? [英] How to use ng-click with multiple expressions?

查看:131
本文介绍了如何使用多前pressions NG-点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用NG-点击执行多个前pressions。我想设置都在模型上的价值,并呼吁从 $范围的方法,就像这样:

I want to use ng-click to perform multiple expressions. I want to both set a value on a model, and call a method from the $scope, like this:

<a ng-click="navigation.book = book && bookSvc.showBook(book)" href="#{{book.id}}">{{book.title}}</a>

在那里我有&放大器;&安培; 分隔两个不同的前pressions我想执行。我知道我可以只补充一点,确实在控制器两件事的方法。我是不是应该这样做,或者是有直接从 NG-点击内完成两个前pressions方式

Where I have && separating the two different expressions I want to perform. I know I could just add a method that does both things in the controller. Should I just do that, or is there a way to perform two expressions directly from inside ng-click?

推荐答案

只需用;分开前pression应该为你工作:

Simply using ';' to separate the expression should work for you:

<a ng-click="navigation.book = book; bookSvc.showBook(book)" href="#{{book.id}}">{{book.title}}</a>

这篇关于如何使用多前pressions NG-点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆