Reputation: 105
I am using the aws-amplify from this site I noticed on this site, this.signedIn
is not used anywhere on this link. I am attempting to use is as an indicator true/false value as to if the user is signed in.
This is the code:
constructor(public mediaObserver: MediaObserver, private amplifyService: AmplifyService ){
this.amplifyService.authStateChange$
.subscribe(authState => {
this.signedIn = authState.state === 'signedIn';
});
console.log('This is from home constructor for signedIn boolean value ', this.signedIn)
this.signedIn is sent to the console window as : undefined
Upvotes: 0
Views: 203
Reputation: 412
The AppComponent
does not set an initial value for signedIn
so by default it will be undefined
:
export class AppComponent {
signedIn: boolean;
...
}
Your console.log(...)
is within the components constructor and so when the log call is hit - the value is still undefined
.
You will still be able to refer to signedIn
from within your template as the undefined
value will resolve to false
. Or you can be more explicit and initialize with signedIn: boolean = false
.
Upvotes: 1