2016-06-28 37 views
0

我在角度2 RC1中使用了異步管道,這導致了對服務器的多重請求。 在Angular2 beta 16中,我使用了share方法來解決這個問題。Angular2中的多個請求RC1

import {Http, Headers, RequestOptions, URLSearchParams} from '@angular/http'; 

在構造函數中正在要求this._http.get(path, options)

在beta版本我使用this._http.get(path, options).share()

+0

什麼問題? –

+0

在我的構造函數中,我使用this.data = this._http.get(path,options);並在我的HTML我使用數據|請求網址兩次的異步請提供我的解決方案。 我認爲你得到了我的問題 –

+0

不,我不明白這個問題。 .share()'在beta.16中工作嗎?你爲什麼不在RC1中使用它? –

回答

0
import 'rxjs/add/operator/share'; 
+0

謝謝你對我有用 –