I would like to have a different side menu when selecting tabs from below. I mean I want my side menus to change when I select a tab.
Can I do this?
Thanks
Phil
One way is to apply (on each item in your menu) a conditional class:
.hidden {
display: none;
}
as an example app.html:
<ion-menu [content]="content">
<!-- The side menu title -->
<ion-header>
<ion-navbar>
<ion-title>{{loc.translate.MENU}}</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<ion-list>
<!-- Show toggle only when first tab -->
<ion-item [class.hidden]="currentTab == firstTab" >
<ion-toggle (ionChange)="toggled()" ></ion-toggle>
<ion-label>Switch Wifi</ion-label>
</ion-item>
<!-- Show only when first tab -->
<button [class.hidden]="currentTab == firstTab" ion-item menuToggle>
<ion-icon item-start name="close"></ion-icon>tab 1 says hello
</button>
<!-- Show only when second tab -->
<button [class.hidden]="currentTab == secondTab" ion-item menuToggle>
<ion-icon item-start name="close"></ion-icon>tab 2 says hello
</button>
<!-- Show only when third tab -->
<button [class.hidden]="currentTab == thirdTab" ion-item menuToggle>
<ion-icon item-start name="close"></ion-icon>tab 3 item here
</button>
<!-- Show always -->
<button ion-item menuToggle>
<ion-icon item-start name="close"></ion-icon>CLose Menu
</button>
</ion-list>
</ion-content>
</ion-menu>
<ion-nav #content [root]="rootPage"></ion-nav>
and on your app.component.ts youll make your way to getting the current Page (or tab) and have your properties firstTab, secondTab and such be defined as the pages so that you can have it compared with the current page.
Related
with ion-split-page added, I am not able to see my side menu options which are displaying properly in mobile view.
`
<ion-app>
<ion-split-pane contentId="main">
<!-- the side menu -->
<ion-menu side="start" menuId="m1" contentId="main">
<ion-header>
<ion-toolbar>
<ion-title>Wanderlust</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<ion-menu-toggle menu="m1">
<ion-item lines="none" routerLink="/places/tabs/discover">
<ion-icon name="business" slot="start"></ion-icon>
<ion-label>Discover Places</ion-label>
</ion-item>
</ion-menu-toggle>
<ion-menu-toggle menu="m1">
<ion-item lines="none" routerLink="/bookings">
<ion-icon name="checkbox-outline" slot="start"></ion-icon>
<ion-label>Your Bookings</ion-label>
</ion-item>
</ion-menu-toggle>
<ion-menu-toggle menu="m1">
<ion-item lines="none" (click)="onLogout()" button>
<ion-icon name="exit" slot="start"></ion-icon>
<ion-label>Logout</ion-label>
</ion-item>
</ion-menu-toggle>
</ion-list>
</ion-content>
</ion-menu>
<!-- the main content -->
<ion-router-outlet id="main"></ion-router-outlet>
</ion-split-pane>
</ion-app>
`
Does anyone know how to solve this issue?
We need to add autoHide="false" attribute on ion-menu-toggle.
<ion-menu-toggle autoHide="false">
I am working in Ionic app and I have used the ion-item in my app and I want select one item before moving to the next page but I am not able to select the item.
This is my shipping.html:
<ion-list *ngFor="let itm of shippingdetails">
<ion-item-divider>
<ion-checkbox slot="end"></ion-checkbox>
<h2>{{itm.name}}</h2>
<p>{{itm.mobile}}</p>
<button ion-button outline item-end>
<ion-icon name="create"></ion-icon>
</button>
<button ion-button outline item-end>
<ion-icon name="trash"></ion-icon>
</button>
</ion-item-divider>
</ion-list>
In this, I am showing the items in the loop. It is showing the data but the problem is that I am not able to select the item. I have also used the checkbox but when using the checkbox, it is not showing the p and h2 tags in the view.
This is result in the html, when using the checkbox it is not showing the p and h2 tag. When I am not using the checkbox, it is showing the p and h2 tag.
Any help is much appreciated.
Just Try This: It Works!
<ion-list *ngFor="let itm of shippingdetails">
<ion-item-divider>
<ion-checkbox slot="end" [disabled]="isCheckboxDisabled" (ionChange)="selectCP(itm)"></ion-checkbox>
<!-- <ion-radio slot="start"></ion-radio> -->
<!-- <ion-toggle slot="start"></ion-toggle> -->
<ion-label>
<h2>{{itm.name}}</h2>
<p>{{itm.mobile}}</p>
<p>{{itm.state}}, {{itm.city}}</p>
<p>{{itm.address}}</p>
<p>Pincode: {{itm.pincode}}</p>
</ion-label>
<button ion-button outline item-end>
<ion-icon name="create"></ion-icon>
</button>
<button ion-button outline item-end>
<ion-icon name="trash"></ion-icon>
</button>
</ion-item-divider>
</ion-list>
In this, It will show the checkbox for all the items and the text also.
i am building a project with ionic 3, and the first 3 pages use the blank ionic template, because it has to do with login, registration and then verification, and afterwards you enter the applications home page, which then i utilized the sidemenu ionic template
i have succeeded in building the application and everything works, but after adding the sidemenu templates it affects the blank templates, if you slide left on the screen the side menu shows..
this is my code..
on the app.html
<ion-menu [content]="content">
<ion-header>
<ion-toolbar>
<ion-title>Menu</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<div style="height:130px;"><img src="assets/imgs/titlebg.jpg"/> </div>
<ion-list>
<button menuClose ion-item *ngFor="let p of pages" (click)="openPage(p)">
{{p.title}} <ion-badge *ngIf="p.badge" end>234</ion-badge>
</button>
</ion-list>
</ion-content>
<ion-footer>
<p align="center" style="color:#333333"> WihofaCITY.com</p>
</ion-footer>
</ion-menu>
<ion-nav id="nav" #content [root]="rootPage"></ion-nav>
on the verify account view template i have this
<ion-header>
<ion-navbar color="">
<ion-title>Current Subscription</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<!---- content goes here ---->
<ion-grid>
<ion-row>
</ion-row>
</ion-grid>
</ion-content>
i removed the menutoggle button but if you slide on those pages, this is what i did
<ion-navbar>
<!------------i removed this section ----------------->
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<!------------i removed this section ----------------->
<ion-title>Current Subscription</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<!---- content goes here ---->
<ion-grid>
<ion-row>
</ion-row>
</ion-grid>
</ion-content>
but yet to no avail, please is there something i was supposed to do, or is not doing? thanks in advance.
You can enable/disable the sidemenu from your controller like below
<ion-menu [content]="content" id="mymenu">
<ion-header>
<ion-toolbar>
<ion-title>Menu</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<div style="height:130px;"><img src="assets/imgs/titlebg.jpg"/> </div>
<ion-list>
<button menuClose ion-item *ngFor="let p of pages" (click)="openPage(p)">
{{p.title}} <ion-badge *ngIf="p.badge" end>234</ion-badge>
</button>
</ion-list>
</ion-content>
<ion-footer>
<p align="center" style="color:#333333"> WihofaCITY.com</p>
</ion-footer>
</ion-menu>
And then in your controller, import MenuController
import { MenuController } from 'ionic-angular';
public menuController:MenuController
menuController.enable(true,"mymenu"); //For Enabling
menuController.enable(false,"mymenu"); //For Disabling
I want to place my footer directly above keypad at the bottom.
HTML:
<ion-footer >
<ion-toolbar>
<ion-buttons>
<button ion-button (click) = getBlurred() >
button1
</button>
<button ion-button >
button2
</button>
<button ion-button >
button3
</button>
</ion-buttons>
{{focusedElement ? focusedElement.value : "null"}}
</ion-toolbar>
</ion-footer>
SCSS:
ion-footer {
position:fixed;
bottom : 0;
}
The fixed property allowed me to place the footer at the bottom.
However, each time i activate the input field, the position changes differently. How can i solve this problem?
I importet an example app (menu) and added a button with icon & text to the menu:
<ion-menu [content]="content">
<ion-header>
<ion-toolbar>
<ion-title>Pages</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<ion-item-divider></ion-item-divider>
<button ion-item icon-left (click)="logout()">
<ion-icon name="log-out"></ion-icon>
Logout
</button>
</ion-list>
</ion-content>
</ion-menu>
<ion-nav #content [root]="rootPage"></ion-nav>
Sadly, this results in a not fully shown Icon (I test my app in Chrome)
you have to use the attribute item-left at ion-icon
<ion-menu [content]="content">
<ion-header>
<ion-toolbar>
<ion-title>Pages</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<ion-item-divider></ion-item-divider>
<button ion-item icon-left (click)="logout()">
<ion-icon item-left name="log-out"></ion-icon>
Logout
</button>
</ion-list>
</ion-content>
</ion-menu>
<ion-nav #content [root]="rootPage"></ion-nav>