如何在angular5中向gloabl(public)变量添加http发布响应?

时间:2018-06-21 10:45:07

标签: typescript

我尝试集成HTTP发布请求。我需要将全局变量的默认值更改为发布请求的响应。

getPermissions(permissions: PermissionParam): Observable<any> {
    console.log('Get permissions', permissions);
    const permisions_data = JSON.stringify(permissions)
    return this.http.post(this.permission_url, permisions_data, {headers: {'Content-Type': 'application/json'}});
}

isPermission(data) {
    this.permissionService.getPermissions(data).subscribe(res => {
        this.permission = res.status // this.permission = false in default as global varible
    },
    // tslint:disable-next-line:no-shadowed-variable
    error => {
        const error_data = JSON.stringify(error);
        console.log(error.error.Message);
    });
    console.log(this.have_permision)
}

0 个答案:

没有答案