【发布时间】:2016-09-27 16:48:57
【问题描述】:
我有以下代码用于 Angular 2 预输入组件:
this.question["input"] = new FormControl();
this.question["input"].valueChanges
.debounceTime(400)
.switchMap(term => this.question['callback'](term))
.subscribe(
data => {
this.question["options"].length = 0;
this.question["options"].push(...data);
}
);
效果很好,但是我正在尝试向此事件添加加载动画,即动画在 FormControl 的值更改时开始,并在返回数据时结束。
这么说有没有办法使用如下代码进入这个方法链?
...
.valueChanges
/* Start Animation or Run Custom Function Here */
.switchMap(term => /* Run AJAX Here */)
.subscribe(
data => {
/* End Animation Here */
}
);
...
感谢任何帮助。
【问题讨论】:
标签: angular typescript observable angular2-forms angular2-animation