8.1.与服务器通讯
Http通讯
dataSource:Observable<any>;
products:Array<any>=[];
construction(private http:Http){
let myHeaders:Headers=new Headers();
myHeaders:append("Authorization","Basic 123456")
this.dataSource=this.http.get('/products',{headers:myHeaders})
.map((res)=>res.json());
}
this.dataSource.subscribe(
(data)=>{
this.products=res.json
})Last updated