私は、ウィンドウをデバウンスする方法を見つけようとしています:observablesを使用してイベントのサイズを変更しています。サイズの変更なしに渡されます(たとえば1秒)。angular2:observablesを使用してウィンドウをデバウンスする方法:resize
https://plnkr.co/edit/cGA97v08rpc7lAgitCOd
import {Component} from '@angular/core'
@Component({
selector: 'my-app',
providers: [],
template: `
<div (window:resize)="doSmth($event)">
<h2>Resize window to get number: {{size}}</h2>
</div>
`,
directives: []
})
export class App {
size: number;
constructor() {
}
doSmth(e: Event) {
this.size = e.target.innerWidth;
}
}
ウィンドウを使用して単純なサンプルである:リサイズ、それは(使用「別のウィンドウにプレビューを起動」)即座に反応することを示しています。
大歓迎です! https://gith.github.com/staltz/868e7e9bc2a7b8c1f754 ;-) –
これは現在、この機能の現在のバグ/問題のようです:https://github.com/angular/angular/issues/13248 –