Angular 进入页面后如何打开侧菜单?
我正在用Google Firestore构建一个Ionic4应用程序,我在其中有一些登录信息。我只想在每次登录应用程序时打开侧菜单 类似于:登录>页面>打开侧菜单。 我该怎么做 这是应用程序页面,用于定义菜单内容Angular 进入页面后如何打开侧菜单?,angular,ionic4,Angular,Ionic4,我正在用Google Firestore构建一个Ionic4应用程序,我在其中有一些登录信息。我只想在每次登录应用程序时打开侧菜单 类似于:登录>页面>打开侧菜单。 我该怎么做 这是应用程序页面,用于定义菜单内容 <ion-app> <ion-menu> <ion-header> <ion-toolbar color="primary"> <ion-tit
<ion-app>
<ion-menu>
<ion-header>
<ion-toolbar color="primary">
<ion-title>Menu</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<ion-item *ngIf="auth.usuario$ | async; then authenticated else guest">
</ion-item>
<ng-template #guest>
<p text-center>Entre Utilizando Suas Credenciais</p>
</ng-template>
<ng-template #authenticated>
<ion-menu-toggle auto-hide="false" *ngFor="let p of appPages">
<ion-item [routerDirection]="'root'" [routerLink]="[p.url]">
<ion-icon slot="start" [name]="p.icon"></ion-icon>
<ion-label>
{{p.title}}
</ion-label>
</ion-item>
</ion-menu-toggle>
<div text-center *ngIf="auth.usuario$ | async as usuario">
<ion-button color="secondary" (click)="auth.deslogar()">Logout</ion-button>
</div>
</ng-template>
</ion-list>
</ion-content>
</ion-menu>
<ion-router-outlet main></ion-router-outlet>
</ion-app>
菜单
Entre Utilizando Suas Credenciais
{{p.title}}
注销
从中可以看出有一个.open()
方法可用
说明:打开菜单。如果菜单已打开或无法打开
如果打开,则返回false
签名:打开(动画?:布尔)=>承诺
验证用户后,默认情况下打开侧菜单的解决方案是使用componentsngOnInit()
方法中的.open()
方法
例如,在验证后加载的组件中:
ngOnInit(){
this.menu.open();
}
你需要添加你的代码没问题,很高兴我能帮上忙!:)