I tried injecting the LoginService into 'topbar.component.ts' in the constructor thusly: private _loginService: LoginService,
,
(and imported it) import { LoginService } from '@account/login/login.service';
However, after logging in, I get a continuous stream of errors on the console:
null: ERROR
null: NullInjectorError: StaticInjectorError(RootModule)[TopBarComponent -> LoginService]:
no debug adapter:
null: ERROR CONTEXT
null: DebugContext_ {view: Object, nodeIndex: 31, nodeDef: Object, elDef: Object, elView: Object}
...
I am returning a custom boolean in the 'authenticationResult' that I want to use in topbar.
2 Answer(s)
-
0
LoginService exists in AccountModule and TopBarComponent is in AppModule.
You can consider putting this custom boolean into AppSessionService.
-
0
@maliming - Thank you for pointing out AppSessionService.
The boolean I wanted on the client was a custom property in User. The simple solution was to add the property (named the same) in UserLoginInfoDto (defined on the server). On the client I added argument
private _appSessionService: AppSessionService
in the constructor, then picked upthis._appSessionService.user.MyCustomBoolean
in ngOnInit().