【发布时间】:2019-06-30 20:56:09
【问题描述】:
我正在使用来自这个site 的aws-amplify,我注意到在这个站点上,this.signedIn 在这个链接的任何地方都没有使用。我正在尝试使用 is 作为指示用户是否登录的真/假值。
这是代码:
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
【问题讨论】:
-
这是异步代码。你应该登录订阅功能。
-
@AbdelrhmanHussien 你是对的。当我将它登录到订阅功能时,它不会显示,因为没有任何改变。我用来确定用户是否登录。根据我登录的本地存储。每次刷新页面时,signedIn 变得未定义。当我登录时,最初登录是真的。 Bue 刷新,它变得未定义
标签: angular aws-amplify