Angularjs   发布时间:2022-04-20  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了typescript – Angular 2中的`change`事件是什么大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Angular 2中的变化事件是什么?什么时候发送,我该如何使用它?
I. e.通过(changE)=“update()”在以下代码订阅了什么?

http://plnkr.co/edit/mfoToOSLU6IU2zr0A8OB?p=preview

import {Component,View,Input,Output,EventEmitter,OnChanges} from '@angular/core'

@Component({
  SELEctor: 'inner-component',template: `
    <label><input type="checkBox" [(ngModel)]="data.isSELEcted"> SELEcted</label>
  `
})
export class InnerComponent {
  data = { isSELEcted: false };
}

@Component({
  SELEctor: 'my-app',template: `
    <p><inner-component (changE)="update()"></inner-component></p>
    <p>The component was @R_262_9531@ed {{Count}} times</p>
  `,directives: [InnerComponent]
})
export class AppComponent {
  count = 0;

  update() {
    ++this.count;
  }
}

PS:Same question in Russian.

这是冒泡的事件:输入发生变化,然后是dom树的气泡,并在内部组件元素上处理.可以通过记录事件来检查:

http://plnkr.co/edit/J8pRg3ow41PAqdMteKwg?p=preview

@Component({
  SELEctor: 'my-app',template: `
    <p><inner-component (changE)="@R_262_9531@e($event)"></inner-component></p>
    <p>The component was @R_262_9531@ed {{Count}} times</p>
  `,directives: [InnerComponent]
})
export class AppComponent {
  count = 0;

  @R_262_9531@e($event) {
    console.log($event,$event.target,$event.currentTarget);
    ++this.count;
  }
}

大佬总结

以上是大佬教程为你收集整理的typescript – Angular 2中的`change`事件是什么全部内容,希望文章能够帮你解决typescript – Angular 2中的`change`事件是什么所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。