通过使用一种方法来发出请求,您通常会返回
Observable<any>
以呼叫者身份订阅:
更改为:
方法:
getDefaultNavbarStyle(templateId): Observable<any> {
switch (templateId) {
case ActiveTemplates.Default:
return this.httpClient.get(this.DEFAULT_TEMPLATE_PATH)
case ActiveTemplates.Quick:
return this.httpClient.get(this.QUICK_TEMPLATE_PATH)
case ActiveTemplates.Front:
return this.httpClient.get(this.FRONT_TEMPLATE_PATH)
}
}
呼叫者:
this.defaultNavbarStyleSubscription = this.builderNavbarService.getDefaultNavbarStyle(this.navbarTemplate).subscribe(response => { this.defaultNavbarStyle = response; });