页面始终加载2倍角度Firebase

时间:2020-03-14 12:53:02

标签: angular firebase nebular

我按照本教程https://fireship.io/lessons/angularfire-google-oauth/的结果https://kewirus-v1.web.app,当我重定向到仪表板或包含标头组件的页面时,始终加载2次,有时第二次加载完成,有时卡住。

有人知道发生了什么事吗?

这是我的header.component.ts

@Component({
  selector: 'ngx-header',
  styleUrls: ['./header.component.scss'],
  templateUrl: './header.component.html',
})
export class HeaderComponent implements OnInit {
  @ViewChild('contentTemplate', { static: false }) contentTemplate: TemplateRef<any>;
  private destroy$: Subject<void> = new Subject<void>();
  userPictureOnly: boolean = false;
  user: any;
  userMenu = [{ title: 'Profile' }, { title: 'Log out' }];
  loggedIn: boolean;

  constructor(private sidebarService: NbSidebarService,
    private menuService: NbMenuService,
    private themeService: NbThemeService,
    private userService: UserData,
    private windowService: NbWindowService,
    public auth: AuthService,
    @Inject(NB_WINDOW) private window,
    private router: Router,
    private breakpointService: NbMediaBreakpointsService) {

  }
  openWindow() {
    this.windowService.open(
      this.contentTemplate,
      { title: 'Free Member' },
    );
  }
  signOut(): void {
    this.auth.signOut();
    this.router.navigateByUrl('/auth/signin');
  }
  ngOnInit() {

    //logout
    this.menuService.onItemClick()
      .pipe(
        filter(({ tag }) => tag === 'my-context-menu'), map(({ item: { title } }) => title)).subscribe(title => {
          if (title == "Log out") {
            this.signOut();
          }
        });
    //logout
  }

  toggleSidebar(): boolean {
    this.sidebarService.toggle(true, 'menu-sidebar');
    return false;
  }

  navigateHome() {
    this.menuService.navigateHome();
    return false;
  }
  openChat() {
    this.router.navigateByUrl('/pages/chat');
  }
}

这是我的标头html

<div class="header-container" *nbIsGranted="['view', 'user']">
  <nb-actions size="small">
    <nb-action style="cursor: pointer;padding: 20px;"><a (click)="openWindow()">Free Member</a></nb-action>
    <nb-action class="control-item">
      <nb-search type="modal-zoomin" tag="modal-zoomin"></nb-search>
    </nb-action>
    <nb-action class="control-item" icon="email-outline" (click)="openChat()"></nb-action>
    <nb-action class="control-item" icon="bell-outline"></nb-action>
    <nb-action class="user-action" *ngIf="auth.user$ | async as user">
      <nb-user [nbContextMenu]="userMenu" [onlyPicture]="userPictureOnly" [name]="user?.displayName" [picture]="user?.photoURL" nbContextMenuTag="my-context-menu">
      </nb-user>  
    </nb-action>
  </nb-actions>
</div>

0 个答案:

没有答案