Html 数据切换=';按钮';仅在角组件中进行条件检查后

Html 数据切换=';按钮';仅在角组件中进行条件检查后,html,angular,user-interface,bootstrap-4,Html,Angular,User Interface,Bootstrap 4,单击时需要检查一些条件,如果返回true,则切换单击的位置 忙碌的 无线电广播 无线电广播 您可以使用以下方法: status:boolean; someMethod(value: string): void { this.status = value; if (your condition) { //Your operation here } else { //your other work. } } 在这里,状态将帮助您存储值并应用条件。您可以将$event传递到example(

单击时需要检查一些条件,如果返回true,则切换单击的位置


忙碌的
无线电广播
无线电广播

您可以使用以下方法:

status:boolean;
someMethod(value: string): void {
this.status = value;

if (your condition) {
  //Your operation here
} else {
 //your other work.
}
}


在这里,状态将帮助您存储值并应用条件。

您可以将
$event
传递到
example()
,这样您就可以访问事件属性,例如
target
target.name
/
target.id
。至少尝试以下方法。将模板中的处理程序更改为传递
$event
(单击)='example($event)
。然后更新处理程序以获取
$event
参数,并根据需要使用它
示例($event){console.log($event.target);}