当前位置:  开发笔记 > 前端 > 正文

Angular2 http同步

如何解决《Angular2http同步》经验,为你挑选了0个好方法。

请帮我在Angular2中做一个关于http with synchronous的例子?

我尝试如下:在组件中:

getAllAddress(){
    this.addressService.getAllAddress().then(
            result => {
                this.data = result.list;
                this.onChangeTable(this.config, null);
                console.log('FIRST');
            }
        );
    console.log('LAST');
}

在服务中:

public getAllAddress(){
    return this.__http.get('LOCATION')
    .map((res) => {
        return res.json()
    })
    .toPromise();
}

但是控制台显示日志在'FIRST'之前是'最后'.

谢谢.

推荐阅读
殉情放开那只小兔子
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有