1-1点击事件

  1. Tips:angular点击事件语法事件名后要加括号eghandleClick()
  1. //app.component.html
  2. <div (click)="handleClick()">{{title}}</div>
  1. //app.component.ts
  2. export class AppComponent {
  3. title = 'my-homework';
  4. handleClick():void{
  5. console.log(this.title)
  6. this.title ="change"
  7. }
  8. }

1-2通过事件获取数据

  1. console.log(this)//获取State中的数据
  2. console.log(this.title)//获取State下的title属性