I have this callback(subscribe) which gets executed when the response for the ajax call has been completed.
this.workerService.isLogin()
.subscribe(res => this.isLoginSuccess = res;
console.log(this.isLoginSuccess);
this.router.navigateByUrl('/employees');
);
It typescript, it is equivalent to:
(function (res) { return _this.isLoginSuccess = res; });
console.log(this.isLoginSuccess);
this.router.navigateByUrl('/employees');
I want the transpilation to be:
(function (res) {
return _this.isLoginSuccess = res;
console.log(this.isLoginSuccess);
this.router.navigateByUrl('/employees');
});
I am new to Typescript.
You need to create a block there:
this.workerService.isLogin()
.subscribe(res => {
this.isLoginSuccess = res;
console.log(this.isLoginSuccess);
this.router.navigateByUrl('/employees');
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.