【问题标题】:why http request respose is not display in angular 2?为什么http请求响应没有以角度2显示?
【发布时间】:2017-05-04 07:12:30
【问题描述】:

我正在尝试在 Angular 2 中使用 http。我从组件创建服务并调用服务。但是我没有在组件中得到响应,为什么?

这是我的代码 https://plnkr.co/edit/YBjCGtuxPdniZ8WEngm2?p=preview

moveToSecond(){
    this.main.getData().subscribe(p =>{
     console.log('test');
     console.log(p)
    })

其次

如何处理angular js中的错误

【问题讨论】:

    标签: angular angular2-routing angular2-forms


    【解决方案1】:

    改变

    return body.data || { };
    

    到

    return body || { };
    

    【讨论】:

    • 请分享plunker
    • 我们还能处理错误吗?如果找不到文件,则在 catch 块中
    猜你喜欢
    • 1970-01-01
    • 2018-02-19
    • 2020-07-08
    • 1970-01-01
    • 1970-01-01
    • 2018-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多