Angular 2 OnChanges
示例
当一个或多个组件或指令属性已更改时触发。
import { Component, OnChanges, Input } from '@angular/core';
@Component({
selector: 'so-onchanges-component',
templateUrl: 'onchanges-component.html',
styleUrls: ['onchanges-component.']
})
class OnChangesComponent implements OnChanges {
@Input() name: string;
message: string;
ngOnChanges(changes: SimpleChanges): void {
console.log(changes);
}
}更改事件将记录
name: {
currentValue: 'new name value',
previousValue: 'old name value'
},
message: {
currentValue: 'new message value',
previousValue: 'old message value'
}
热门推荐
10 新婚男士祝福语大全简短
11 新婚简短祝福语微信
12 牛年祝福语简短16字
13 伴娘送亲祝福语简短精辟
14 考取名校祝福语简短
15 毕业祝福语小长句简短
16 商业装修开工祝福语简短
17 爱情格言简短婚礼祝福语
18 开工小花束祝福语简短