我嘗試但我看到一些例子中,在回答檢索由可觀察Angular2:AsyncPipe和可觀的,不能檢索屬性(類型錯誤:無法讀取...空的屬性)
返回對象的屬性所以,在我的應用程序,我得到錯誤。同樣的錯誤轉載於Plunker:
http://plnkr.co/edit/X5xNDOFmCpLOnzv4X0xo?p=preview
@Component({
selector: 'my-app',
providers: [AppService, HTTP_PROVIDERS],
template: `<h1>.?</h1>
<div *ngIf = "data$">
{{(data$ | async)?.total}}
</div>`
})
export class AppComponent {
data$ : Observable<any> = null;
constructor (private appservice : AppService) {}
ngOnInit(){
this.data$ = this.appservice.getData();
}
}
因爲它建議我使用安全導航操作,但它並不能幫助(?)。
至於我記得他們介紹RC.5錯誤解決方法(應該是已經確定)https://github.com/angular/angular/issues/10639 –