在我的角度应用程序中,我正在调用服务并获取数据,一旦获取结果,我需要添加控制台日志。在哪里可以添加控制台日志?
this.searchTerm.asObservable()
.debounceTime(300)
.distinctUntilChanged()
.switchMap(term => this.doFind(term))
.subscribe(data => this.results = data
, error => {
this.errorMessage = error;
});
使用代码块
this.searchTerm.asObservable()
.debounceTime(300)
.distinctUntilChanged()
.switchMap(term => this.doFind(term))
.subscribe(data => {
this.results = data;
console.log('data', data);
})
, error => {
this.errorMessage = error;
});
or the do
操作员
this.searchTerm.asObservable()
.debounceTime(300)
.distinctUntilChanged()
.switchMap(term => this.doFind(term))
.do(val => condole.log(val))
.subscribe(data => this.results = data
, error => {
this.errorMessage = error;
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)