im有點新的angular2,我希望你能幫助我我很肯定它必須是簡單的東西,但這是交易即時通訊服務,可以處理http調用,但它的需要應用一些過濾器中的數據,而不要求加載之後再次以新的參數基本上我想要讓angular2處理的那部分angular 2 rc4從Http observable獲取數據後創建變量
更新** API服務器
服務
httpHandler(type,model){var token = this.LoginService.JwtDecoded(); var authHeader = new Headers(); authHeader.append('Authorization', 'Bearer ' + token);
return this.http.get('http://127.0.0.1/api/service/'+model, { headers: authHeader }) .map((res: Response) => res.json()); }
組件
this.Request.httpHandler('get','receiver/') .subscribe( data => this.data = data, <-- from here err => this.error = 'there is a mistake!', () => console.log(this.data) <-- this one is outputing just what i want ); console.log(data); <-- i wanna output the same result in here
所以,我怎樣才能捕捉API導致到一個變量?
更新** 我想輸出'this.data'外部訂閱,奇怪的是,我可以輸出內部訂閱和在html中,但我需要做一些與該json輸出前的東西在html中。任何想法的傢伙?謝謝!
感謝您的時間夥計,非常感謝。
可爲了有一個最小的,完整的和可驗證的例子,你應該詳細說明你目前的問題是什麼。它現在做了什麼,爲什麼這是錯的? – bpachev