【发布时间】:2019-05-08 04:02:06
【问题描述】:
我是 Angular 和 JHipster 的新手。请帮助解决问题。我没有更改那里的代码。有jhipster的默认登录码。
堆栈跟踪:
TypeError: this.accountService 未定义 堆栈跟踪: LoginService.prototype.logout@webpack-internal:///./src/main/webapp/app/core/login/login.service.ts:33:9 NavbarComponent.prototype.logout@webpack-internal:///./src/main/webapp/app/layouts/navbar/navbar.component.ts:49:9 View_NavbarComponent_30/
核心/登录/login.service.ts:
import { AccountService } from 'app/core/auth/account.service';
--------------------------------------------------
constructor(private accountService: AccountService)
--------------------------------------------------
login(credentials, callback?) {
const cb = callback || function() {};
return new Promise((resolve, reject) => {
this.authServerProvider.login(credentials).subscribe(
data => {
this.accountService.identity(true).then(account => {
resolve(data);
});
return cb();
},
err => {
this.logout();
reject(err);
return cb(err);
}
);
});
}
logout() {
this.authServerProvider.logout().subscribe();
this.accountService.authenticate(null);
}
core/auth/account.service.ts:
export class AccountService {
--------------------------------
authenticate() {
some code;
}
identity() {
some code;
}
--------------------------------
}
【问题讨论】:
标签: angular typescript login jhipster