2
在Angular1中,我能夠爲ng-model
添加添加去抖時間。angular2,指令輸入OnChanges延遲(去抖動)?
在Angular2中,我們可以檢測到所有input
的變化。每次輸入更改是否可能有一些去抖動時間?
從以下plunker示例http://plnkr.co/edit/JKYSek?p=preview中,我輸入「hello world」,但它對每一個關鍵筆畫都有反應。
是否有可能在沒有任何編程的情況下每次更改都會有一些延遲?
import { Directive, OnChanges } from "@angular/core";
@Directive({
selector: '[my-directive]',
inputs: [`myInput`]
})
export class MyDirective implements OnChanges {
ngOnChanges(changes: {[key: string]: SimpleChange}) {
console.log('changes :'+ changes.myInput.currentValue);
}
}