Angular 2中基于条件的点击事件 [英] Condition based click event in Angular 2

查看:112
本文介绍了Angular 2中基于条件的点击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我希望有一个基于条件的点击事件

In my application I would like to have conditional based click event ,

<div class="trashIconDiv" (click)="if(idx > 0) {removeSelected(item.spId)}">

在上面的代码中,只有在idx> 0时,才应执行removeSelected函数

In the above code removeSelected function should be executed only when idx >0 , any idea how to implement

推荐答案

(click)="idx > 0 && removeSelected(item.spId)"

这篇关于Angular 2中基于条件的点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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