本文整理匯總了TypeScript中angular2/angular2.Http.get方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Http.get方法的具體用法?TypeScript Http.get怎麽用?TypeScript Http.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類angular2/angular2.Http
的用法示例。
在下文中一共展示了Http.get方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: constructor
constructor(http: Http) {
this.data = {};
http.get('foo.json')
.map(res => res.json())
.subscribe(data => {
this.data = data;
console.log(this.data);
})
}
示例2: _callApi
_callApi(type, url) {
this.response = null;
this.api = type;
var headers = new Headers();
headers.append('Accept', 'application/json');
headers.append('Content-Type', 'application/json');
headers.append('Authorization', 'bearer ' + this.jwt);
this.http.get(url, {headers: headers})
.toRx()
.map(status)
.map(text)
.subscribe(
response => {
this.response = response;
},
error => {
this.response = error.message;
}
)
}
示例3: retrieveData
retrieveData() {
this.http.get('http://www.dynamopackages.com/packages/');
//.map(res => res.json()).subscribe(data => { this.data = data.content;})
}