繼2角度的文檔,具體https://angular.io/docs/ts/latest/guide/server-communication.html與代碼示例在普朗克here - 我試圖模擬錯誤情況破碎的服務器鏈接(這樣調用)。顯示錯誤的類型net :: ERR_CONNECTION_REFUSED
GET http://localhost:3002/heroes net::ERR_CONNECTION_REFUSED
scheduleTask @ zone.js:1990
ZoneDelegate.scheduleTask @ zone.js:384
onScheduleTask @ zone.js:274
然而,在模板HTML {{errorMessage}}
我越來越0 - {"isTrusted":true}
。如何收集錯誤信息net::ERR_CONNECTION_REFUSED
?
請注意,需要將import 'rxjs/add/observable/throw';
添加到該服務,以避免出現否則會遇到的錯誤 - TypeError: Observable_1.Observable.throw is not a function
。