我有这个回调(subscribe),它在ajax调用的响应完成后执行。
this.workerService.isLogin()
.subscribe(res => this.isLoginSuccess = res;
console.log(this.isLoginSuccess);
this.router.navigateByUrl('/employees');
);
它打字稿,相当于:
(function (res) { return _this.isLoginSuccess = res; });
console.log(this.isLoginSuccess);
this.router.navigateByUrl('/employees');
我希望转换为:
(function (res) {
return _this.isLoginSuccess = res;
console.log(this.isLoginSuccess);
this.router.navigateByUrl('/employees');
});
我是新手稿。
答案 0 :(得分:1)
你需要在那里创建一个块:
this.workerService.isLogin()
.subscribe(res => {
this.isLoginSuccess = res;
console.log(this.isLoginSuccess);
this.router.navigateByUrl('/employees');
});