My current bootstrap and vue versions:
"bootstrap": "^5.2.3", "bootstrap-icons": "^1.10.3", "bootstrap-vue": "^2.23.1", "jquery": "^3.6.3", "popper.js": "^1.16.1", "vue": "^3.2.47",
My code:
<template>
<div>
<b-card no-body>
<b-tabs card>
<b-tab title="Tab 1" active>
<b-card-text>Tab contents 1</b-card-text>
</b-tab>
<b-tab title="Tab 2">
<b-card-text>Tab contents 2</b-card-text>
</b-tab>
</b-tabs>
</b-card>
</div>
</template>
Hope everyone can help me. Thank you very much.
It just shows up like this:
enter image description here
these are my stencil and ionic version
"dependencies": {
"#ionic/core": "one"
},
"devDependencies": {
"#stencil/core": "1.0.0-beta.8"
}
I'm trying to use the <ion-menu> inside a <ion-split-pane> like in a ionic app, this is my code (this is the original repo of this code https://github.com/modemlooper/stencil-pwa-sidemenu ):
app-root.tsx
[...]
render() {
return (
<ion-app>
<ion-router useHash={false}>
<ion-route url="/" component="app-home" />
<ion-route url="/profile/:name" component="app-profile" />
</ion-router>
<ion-split-pane when="lg">
<ion-menu side="start">
<ion-header>
<ion-toolbar color="primary" />
</ion-header>
<ion-content forceOverscroll={false}>
<ion-list>
<ion-menu-toggle autoHide={false}>
<ion-item href="/">
<ion-icon slot="start" name="home" />
<ion-label>Home</ion-label>
</ion-item>
</ion-menu-toggle>
<ion-menu-toggle autoHide={false}>
<ion-item href="/profile/piero">
<ion-icon slot="start" name="person" />
<ion-label>Profile</ion-label>
</ion-item>
</ion-menu-toggle>
</ion-list>
</ion-content>
</ion-menu>
<ion-nav main />
</ion-split-pane>
</ion-app>
);
}
[...]
The problem is that <ion-nav main /> gives me this error:
And without "main" the split pane don't work properly
This is the expected behaviour
How is it possible to fix this? I don't get how to use properly the ion menu inside a split pane...
Thank you so much
I have the split-pane working in an app. There are a couple differences with your implementation:
ion-nav is wrapped in an ion-content element with an ID attribute
The ion-contents ID is referenced in ion-split-pane[contentId] and ion-menu[contentId]
<ion-split-pane contentId="main-content">
<ion-menu contentId="main-content">
...
</ion-menu>
<ion-content id="main-content">
<ion-nav />
</ion-content>
</ion-split-pane>
In my ionic select i got output like small down arrow rather than a full select tag and for input tag just a blank space. I can enter data but UI not looks good. Is there any css i need to add.
<ion-card class='sc-ion-card-md-h'>
<ion-card-header>
<ion-card-subtitle>Name:</ion-card-subtitle>
<ion-card-title>
<ion-select #inputName id="username" class="form-control">
<ion-select-option>SELECT</ion-select-option>
<ion-select-option>Monicka</ion-select-option>
<ion-select-option>Hema</ion-select-option>
<ion-select-option>Ramesh</ion-select-option>
<ion-select-option>Madhavan</ion-select-option>
<ion-select-option>Aadhavan</ion-select-option>
<ion-select-option>Madhan</ion-select-option>
<ion-select-option>Prasanth</ion-select-option>
</ion-select>
</ion-card-title>
</ion-card-header>
<ion-card-header>
<ion-card-subtitle>Date:</ion-card-subtitle>
<ion-card-title>
<ion-input type="text" #inputDate id="date" class="form-control"></ion-input>
</ion-card-title>
</ion-card-header>
</ion-card>
Output looks like this...
It seems like you are trying to convert a Bootstrap form over to Ionic and you are bringing some jQuery thinking along with it.
This is how you would do it with an Ionic page:
page.html
<ion-header>
<ion-toolbar>
<ion-title>card-select</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-card>
<ion-list>
<ion-item>
<ion-label position="stacked">Name:</ion-label>
<ion-select [(ngModel)]="username" placeholder="SELECT">
<ion-select-option>Monicka</ion-select-option>
<ion-select-option>Hema</ion-select-option>
<ion-select-option>Ramesh</ion-select-option>
<ion-select-option>Madhavan</ion-select-option>
<ion-select-option>Aadhavan</ion-select-option>
<ion-select-option>Madhan</ion-select-option>
<ion-select-option>Prasanth</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label position="stacked">Date:</ion-label>
<ion-input [(ngModel)]="date"></ion-input>
</ion-item>
</ion-list>
</ion-card>
</ion-content>
page.ts
import { Component, OnInit } from '#angular/core';
#Component({
selector: 'app-card-select',
templateUrl: './card-select.page.html',
styleUrls: ['./card-select.page.scss'],
})
export class CardSelectPage implements OnInit {
username: string;
date: string;
constructor() { }
ngOnInit() {
}
}
notes
You don't need all those classes you put on.
Using label position="stacked" puts it above the input.
You dont need to bind the name like #username or id="username". What you do is put a variable on the page behind it and then use ngModel to bind to it. Any change that is made to the user interface (typing into a box, selecting an option) is then automatically set to the variable in the page. This works both ways because of the [()] syntax, so if you change username with something like this.username = "superman"in the code then the input box on the page will automatically update to match that value as well.
You don't need type="text" on the input, its the default.
You can use the placeholder attrib to pass some SELECT text instead of having an extra select option.
I use ion-menu component in my app. I change it based route. so I modified that. For ex is below.
My issue is first time menu clicked & the app load next that menu
related view time the side menu was close correctly but reopened next few second.
My approutemodule.ts
[{
path: '',
canActivate: [AuthGuard],
component: SideMenuComponent,
children: [{
path: '',
redirectTo: 'dashboard',
pathMatch: 'full'
}, {
path: 'dashboard',
loadChildren: './pages/dashboard/dashboard.module#DashboardPageModule'
}, {
path: 'tabs-view',
loadChildren: './layouts/footer-tabs/footer-tabs.module#FooterTabsPageModule'
}]
}, {
path: 'login',
loadChildren: './pages/login/login.module#LoginPageModule'
}];
My appcomponent.html
<ion-app>
<ion-router-outlet></ion-router-outlet>
</ion-app>
My sidemenucomponent.html
<ion-split-pane>
<ion-menu id="app-side-manu" #sideMenu>
<ion-header class="user-img">
<ion-toolbar>
<ion-avatar>
<img *ngIf="userImg" [src]="userImg" alt="user-img" />
</ion-avatar>
<div>
<h2>{{userName}}</h2>
<p>{{userLoc}}</p>
</div>
</ion-toolbar>
</ion-header>
<ion-content class="side-menu">
<ion-list>
<ion-menu-toggle auto-hide="false" *ngFor="let p of pages">
<ion-item lines="none" class="link-hover" routerDirection="root" [routerLink]="p.url">
<ion-thumbnail slot="start">
<ion-img [src]="p.icon"></ion-img>
</ion-thumbnail>
<ion-label>
{{p.title}}
</ion-label>
</ion-item>
</ion-menu-toggle>
<ion-menu-toggle auto-hide="false" >
<ion-item lines="none" class="link-hover" (click)="globalHelper.logout()">
<ion-thumbnail slot="start">
<ion-img src="/assets/images/logout.png"></ion-img>
</ion-thumbnail>
<ion-label>Logout</ion-label>
</ion-item>
</ion-menu-toggle>
</ion-list>
</ion-content>
</ion-menu>
<ion-router-outlet main></ion-router-outlet>
</ion-split-pane>
Use side-menu component selector in your app component html file.
For Ex:
<ion-app>
<app-sidemenu-component></app-sidemenu-component>
</ion-app>
If you want side-menu show hide different screen. It's possible.
For Ex:
home screen is need to side-menu
// first import MenuController in your home screen
import { MenuController } from '#ionic/angular';
// Next add that constructor to assign private variable menuCtrl
constructor(private menuCtrl: MenuController){}
// then use it ionViewWillEnter method inside
ionViewWillEnter() {
this.menuCtrl.enable(true);
}
login screen is no need to side-menu
ionViewWillEnter() {
this.menuCtrl.enable(false);
}
i followed this article to combine sidemenu and Tabs pages.
the app.html has my menu. i have with #nav bind the ion-nav to [Content] of my ion-menu.
in my app.component.ts i have click Events. they set different Tabs pages as root and there is one normal page.
this looks like this:
#ViewChild('nav') nav: NavController;
public OnInformationClicked(): void {
this.nav.setRoot("InfoTabsPage");
}
public OnManagementClicked(): void {
this.nav.setRoot("ManagementTabsPage");
}
//some other Tabs pages
//the normal page
public OnFaqClicked(): void {
this.nav.setRoot("FaqPage");
}
in my tabs pages i'm using [selectedIndex] like this:
<ion-header>
<ion-navbar>
<ion-buttons left>
<button ion-button icon-only menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
</ion-buttons>
</ion-navbar>
</ion-header>
<ion-tabs [selectedIndex]="0">
<ion-tab [root]="contactPersonRoot" tabTitle="{{tabs1Name}}" tabIcon="information-circle"></ion-tab>
<ion-tab [root]="contactSupportRoot" tabTitle="{{tabs2Name}}" tabIcon="information-circle"></ion-tab>
</ion-tabs>
but it is not working.
Problem:
when i open my menu and change the tabs pages, i can see, how the tabs changed and the right tab Icon is selected, but the Content over the tabs doesn't changed.
if i going to the normal page, this is displayed correctly. if i going to a Tabs page from the normal page, then the Tabs page is displayed correctly. if i'm trying to go back to another tabs page. it doesn't changed all content again.
i tried .... MyTabs.select(0). same issue.
i'm currently tesing with ionic serve.
"ionic-angular": "3.9.2",
"ionicons": "4.1.2",
"#angular/animations": "6.0.3",
"#angular/common": "6.0.3",
"#angular/compiler": "6.0.3",
"#angular/compiler-cli": "6.0.3",
"#angular/core": "6.0.3",
"#angular/forms": "6.0.3",
"#angular/http": "6.0.3",
"#angular/platform-browser": "6.0.3",
"#angular/platform-browser-dynamic": "6.0.3",
"#ionic-native/app-version": "^4.10.0",
"#ionic-native/background-mode": "^4.10.0",
"#ionic-native/camera": "^4.10.0",
"#ionic-native/core": "4.7.0",
"#ionic-native/in-app-browser": "^4.9.1",
"#ionic-native/network": "^4.7.0",
"#ionic-native/splash-screen": "4.7.0",
"#ionic-native/status-bar": "4.7.0",
"#ionic/storage": "^2.1.3",
anyone an idea, what's going wrong?
UPDATE
after try and error coding, changed from [selectedIndex]="0" back to myTabs.select(0) in the .ts file of the tabs page like in the article. this not working.
but i made a timeout around like so:
ionViewDidLoad() {
let _self = this;
setTimeout(function(){
_self.tabRef.select(0);
},100);
}
now i can see, the content over the tabs replaced correctly. but it looks not like a good workaround, because now i see that the old content is loading before the replacement by select.
if i open tabspage 2 now, i can see from tabspage 1 is the content behind tab 1 rendered (ionViewDidLoad, ionViewWillEnter... of tab 1 is executing). then after selecting is done, tab 1 of tabspage 2 is rendering.
UPDATE 2
app.html:
<ion-menu [content]="nav">
<ion-header>
<ion-toolbar>
<ion-title>{{menuTitle}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<button ion-item (click)="OnInformationClicked()">
<ion-icon name="information" item-start color="primary"></ion-icon>
<ion-label>Info</ion-label>
</button>
<button ion-item (click)="OnManagementClicked()">
<ion-icon name="build" item-start color="primary"></ion-icon>
<ion-label>Manage</ion-label>
</button>
<button ion-item (click)="OnRealisationClicked()">
<ion-icon name="clipboard" item-start color="primary"></ion-icon>
<ion-label>Real</ion-label>
</button>
<button ion-item (click)="OnContactClicked()">
<ion-icon name="contact" item-start color="primary"></ion-icon>
<ion-label>Contact</ion-label>
</button>
<button ion-item (click)="OnFaqClicked()">
<ion-icon name="help" item-start color="primary"></ion-icon>
<ion-label>FAQ</ion-label>
</button>
<button ion-item (click)="OnLogoutClicked()">
<ion-icon name="log-out" item-start color="primary"></ion-icon>
<ion-label>Logout</ion-label>
</button>
</ion-list>
</ion-content>
</ion-menu>
<ion-nav [root]="rootPage" #nav [swipeBackEnabled]="false"></ion-nav>
app.component.ts
#Component({
templateUrl: 'app.html'
})
export class MyApp {
#ViewChild('nav') nav: NavController;
public menuTitle: string = GlobalHelper.GetResources().Application.Menu.Menu;
rootPage: any = HomePage;
constructor(private _css: ClientServerProvider, platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen,
private _backgroundMode: BackgroundMode, private _appProvider: AppProvider) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
_backgroundMode.enable();
});
}
public OnInformationClicked(): void {
this.nav.setRoot("InfoTabsPage");
}
public OnManagementClicked(): void {
this.nav.setRoot("ManagementTabsPage");
}
public OnRealisationClicked(): void {
this.nav.setRoot("RealisationTabsPage");
}
public OnContactClicked(): void {
this.nav.setRoot("ContactTabsPage");
}
public OnFaqClicked(): void {
this.nav.setRoot("FaqPage");
}
public OnLogoutClicked(): void {
this._css.Logout().then(loggedOut => {
if (loggedOut) {
this._appProvider.InitApplication();
}
});
}
}
for example one of the Tabs pages (the others are like this):
<ion-header>
<ion-navbar>
<ion-buttons left>
<button ion-button icon-only menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
</ion-buttons>
</ion-navbar>
</ion-header>
<ion-tabs #myTabs>
<ion-tab [root]="preparationRoot" tabTitle="{{tabs1Name}}" tabIcon="browsers"></ion-tab>
<ion-tab [root]="processRoot" tabTitle="{{tabs2Name}}" tabIcon="logo-buffer"></ion-tab>
<ion-tab [root]="complaintRoot" tabTitle="{{tabs3Name}}" tabIcon="bulb"></ion-tab>
</ion-tabs>
import { Component, ViewChild } from '#angular/core';
import { IonicPage, NavController, MenuController, Tabs } from 'ionic-angular';
import { GlobalHelper } from '../../../../helper/globalHelper';
#IonicPage()
#Component({
selector: 'page-realisation-tabs',
templateUrl: 'realisation-tabs.html'
})
export class RealisationTabsPage {
#ViewChild('myTabs') tabRef: Tabs;
preparationRoot = 'PreparationPage';
processRoot = 'ProcessPage';
complaintRoot = 'ComplaintPage';
tabs1Name = GlobalHelper.GetResources().Application.Features.Realization.Preperation_Page_Header;
tabs2Name = GlobalHelper.GetResources().Application.Features.Realization.Process_Page_Header;
tabs3Name = GlobalHelper.GetResources().Application.Features.Realization.Complaint_Page_Header;
constructor(public menuCtrl: MenuController, public navCtrl: NavController) {
}
ionViewDidLoad() {
// after OnRealisationClicked
/*
*
* with this workaround, Tabs changed, content (subpage) changed, correct * tab is active, but before the subpage changed to correct one, the previous
* subpage is loading , nearly the result of the guide in the article
let _self = this;
setTimeout(function () {
_self.tabRef.select(0);
}, 100);*/
// this is the variant of the article, without timeout
//only Tabs are changed and the correct tab Icon is active and selected
// but content (subpage) is not changed, it is still the first subpage
//of the previous tabspage
this.tabRef.select(0);
}
}
Workflow (without the timeout workaround):
after Login HomePage as root is replaced with RealisationTabsPage, Tab 1 subpage (preparation) is loaded
open Menu Click on a menu Point, which open another Tabs page, for example contacttabspage
Tabs of the contacttabspage are loaded. tab 1 of this Tabs is selected and active. but the subpage behind tab 1 of contacttabspage is still the subpage from realisationtabspage (preparation).
now i'm open menu and going to a None Tabs page (FAQ). FAQ is correctly rendered.
open menu: i'm going to a Tabs page, never mind which Tabs page (Realization, contact, info, mangement...), Tabs page rendered correctly.
now i'm going from this tabspage to another tabspage , so there is the issue again. i'm see the previous subpage of the previous tabspage.
if i'm using instead of using the select() function there is the same issue.
Made this working example of sidemenu+tabs.Hope it helps you.
https://stackblitz.com/edit/ionic-hmkkwc
I had a similar problem. Assign the pages directly to the tab variables instead of the string representation (page names) AND give the tab container unique ids. That worked for me.