我已经创建了供应商页面,我正在发帖并在其中收到请求
这是我的返回可观察的服务
post(url: string,data:any): Observable<any>{
return this.http.post(this.configurator.restServerBaseUrl+url,data)
.map((result:Response)=> {
result.json()
})
}
这是我的组件代码
submit(){
this.rest.post('/validateUser',validateUserObj)
.subscribe((result)=>{
this.logger.debug("checking data of success " +JSON.stringify(result));
});
}
}
我的结果是 undefined
in my services if i map like this it works fine
.map((result:Response)=>result.json())
如果我应用括号,我将变得不确定。
can some one help me in understand the observable i have checked in angula.io but i am feeling difficult to understand there
最佳答案
简写形式隐式返回expression
的结果
(param) => expression;
带括号的长格式支持多条语句,但你必须显式return
(param) => {
let x = this.doSomething();
return x;
}
关于HTTP observable 返回 undefined/null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40908126/