我想利用在angular2观测和糊涂了,为什么我应该使用map()过subscribe().假设我从webApi获取值,就像这样
this.http.get('http://172.17.40.41:8089/api/Master/GetAllCountry')
Run Code Online (Sandbox Code Playgroud)
现在使用subscribe(success, error, complete)我可以获得成功回调的所有值,我可以返回完整回调的值.如果我可以做所有这些功能,那么需要map()什么?它有什么优势吗?
简而言之,为什么人们应该这样写:
this.http.get('http://172.17.40.41:8089/api/Master/GetAllCountry')
.map(r=>{})
.subscribe(value => {
}, error => error, () => {
});
Run Code Online (Sandbox Code Playgroud)
当他们可以简单地写这个没有map函数:
this.http.get('http://172.17.40.41:8089/api/Master/GetAllCountry')
.subscribe(value => {
}, error => error, () => {
});
Run Code Online (Sandbox Code Playgroud)