点击功能不工作angular2

时间:2017-11-07 13:57:54

标签: angular

我在运行时在组件内创建按钮,而(单击)不是在监听事件

app.component.ts

{{1}}

1 个答案:

答案 0 :(得分:1)

 <button (click)="myFunc()"></button>

import { Component, OnInit } from "@angular/core";

@Component({
  templateUrl:"button.html" //this is the component which has the above button html
})

export class App implements OnInit{
  constructor(){}

  ngOnInit(){

  }

  myFunc(){
    console.log("function called");
  }
}
相关问题