am using ion-side-menus in the ionic-1 project if I click side menu options the functionalities worked but side menu doesn't close. Is possible to access menu-close directive in the controller.
Html:
<ion-side-menus enable-menu-with-back-views="false">
<ion-side-menu side="left">
<ion-content>
<ion-list>
<ion-item class="item item-icon-left" menu-close on-touch="vm.goSechemeList()">
<i class="icon ion-document-text"></i> {{'SCHEMES' | translate }}
</ion-item>
</ion-list>
</ion-content>
<ion-side-menu>
</ion-side-menus>
Controller:
function goSechemeList () {
$log.log('click scheme list');
Analytics.trackEvent(Track.Secure_schemelist);
$state.go('secure.layout.schemes');
}
use ng-click instead on-touch
Like: ng-click = "goSechemeList()"
Hope this help:)
Related
I am trying to add pages with links in navigation bar(to be in middle). On the right I want to have nav button which on click open the side bar on the right. For now I just put the nav button but I cant figure how to put links in center of navigation bar. Code example:
<ion-side-menus>
<ion-side-menu-content>
<ion-nav-bar class="bar-stable">
<ion-nav-back-button ng-click="myGoBack()">
</ion-nav-back-button>
<ion-nav-buttons side="right">
<button class="button button-icon button-clear ion-navicon" menu-toggle="right">
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-nav-view name="menuContent">
</ion-nav-view>
</ion-side-menu-content>
<ion-side-menu side="right">
<ion-content>
<ion-list>
<ion-item menu-close ng-click="">
Traveler
</ion-item>
<ion-item menu-close href="">
Pinko
</ion-item>
<ion-item menu-close href="">
Club
</ion-item>
<ion-item menu-close ng-click="">
My Agency
</ion-item>
<ion-item menu-close href="">
My Karma
</ion-item>
<ion-item menu-close href="">
Notification
</ion-item>
<ion-item menu-close href="">
Profile
</ion-item>
<ion-item menu-close href="">
Settings
</ion-item>
</ion-list>
</ion-content>
</ion-side-menu>
</ion-side-menus>
Aslo here is an image so you can see what I need:
I don't know how you are handling the transition to different $states, but you can try to insert the links inside the <ion-nav-title> tag in the following way:
<ion-nav-title align='center'>
<span>Link 1</span>
<span>Link 2</span>
<span>Link 3</span>
</ion-nav-title>
Then if you want to move the title on the left side like in the image you have attached, you can use $ionicNavBarDelegate inside your controller with $ionicNavBarDelegate.align('left').
Finally if you want to modify the spacing or the color of the links, do it via css like I did in this fiddle. I hope that my answer helps you!
I have problem removing an animation to my ionic app. The main problem is I dont know how to disable side bar opening on screen swipe. I want my side bar just open on click the nav-icon not to open on page swipe.
My nav code is here:
<ion-side-menus>
<ion-side-menu-content>
<ion-nav-bar class="bar-traveler">
<ion-nav-back-button>
</ion-nav-back-button>
<ion-nav-title class="heder-tabs">
<span><a >Travel</a></span>
<span><a >Location</a></span>
<span><a >Networking</a></span>
</ion-nav-title>
<ion-nav-buttons side="right">
<button class="button button-icon button-clear ion-navicon" menu-toggle="right">
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-nav-view class="has-header"></ion-nav-view>
</ion-side-menu-content>
<ion-side-menu side="right">
<ion-content>
<ion-list>
<ion-item menu-close ng-click="">
Traveler
</ion-item>
<ion-item class="side-navigation-pinko" menu-close href="">
<div class="pinko-nav">
<div class="pinko-sidenav-logo">
<img src="img/pro4travel-logo.png">
</div>
<div class="first-three-nav-choice">Pinko</div>
</div>
</ion-item>
<ion-item menu-close href="">
Club
</ion-item>
<ion-item menu-close ng-click="">
My Agency
</ion-item>
<ion-item menu-close href="">
My Karma
</ion-item>
<ion-item menu-close href="">
Notification
</ion-item>
<ion-item menu-close href="">
Profile
</ion-item>
<ion-item menu-close href="">
Settings
</ion-item>
</ion-list>
</ion-content>
</ion-side-menu>
</ion-side-menus>
Find solution myself. I have just added to ion-side-menu-content an drag-content like this:
<ion-side-menu-content drag-content="false">
We are working on an application, which uses ngCordova and would like to implement a side menu. The side menu has been implemented, as shown below.
After adding the subheader, the menu looks like this:
This is our code for the side menu:
<ion-view title="Home" ng-app="app.controllers" >
<ion-header-bar class="bar bar-subheader bar-positive">
<h1 class="title">Subheader</h1>
</ion-header-bar>
<ion-side-menus ng-controller="homeCtrl">
<ion-side-menu-content>
<ion-nav-bar class="bar-stable nav-title-slide-ios7">
<ion-nav-buttons side="left">
<button class="button button-icon button-clear ion-navicon" menu-toggle="left">
</button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-nav-view name="menuContent"></ion-nav-view>
</ion-side-menu-content>
<ion-side-menu side="left" >
<ion-header-bar class="bar-stable bar-dark">
<h1 class="title">Category</h1>
</ion-header-bar>
<ion-list class="dark">
<ion-item nav-clear menu-close href="" class="item item-icon-left" >
<i class="icon ion-ios7-ionic-outline ion-ios-home-outline"></i><span style="color:#666">Home</span>
</ion-item>
<ion-item nav-clear menu-close href="#/tab/home" class="item item-icon-left" >
<i class="icon ion-ios7-help ion-ios-home-outline"></i><span style="color:#666">Home</span>
</ion-item>
<ion-item nav-clear menu-close href="" class="item item-icon-left" >
<i class="icon ion-ios7-help ion-ios-paw-outline"></i><span style="color:#666">Dogs</span>
</ion-item>
<ion-item nav-clear menu-close href="" class="item item-icon-left" >
<i class="icon ion-ios7-help ion-ios-cog-outline"></i><span style="color:#666">Profile Settings</span>
</ion-item>
<ion-item nav-clear menu-close href="" class="item item-icon-left" >
<i class="icon ion-ios7-help ion-ios-checkmark-outline"></i><span style="color:#666">History Orders</span>
</ion-item>
</ion-list>
</ion-side-menu>
</ion-side-menus>
</ion-view>
We would like the subheader to move left and right like the menu button, but it is not doing that right now. How can I solve this issue?
You are defining the subheader outside of the element for the side menu, which is why it is not acting the way you would like it to. You can solve this by moving the following code:
<ion-header-bar class="bar bar-subheader bar-positive">
<h1 class="title">Subheader</h1>
</ion-header-bar>
To the<ion-side-menu side="left>:
<ion-side-menu side="left">
<ion-header-bar class="bar-stable bar-dark">
<h1 class="title">Category</h1>
</ion-header-bar>
<ion-header-bar class="bar bar-subheader bar-positive">
<h1 class="title">Subheader</h1>
</ion-header-bar>
so I am currently doing a side menu for my Single Page Application, I got the side menu working, but I cannot display the main content. I am not sure what went wrong. I cannot display the word hello world in my page. Any one has an idea?
Here is my code
<ion-tab title="Draft" ng-controller="textController">
<ion-side-menus>
<ion-side-menu-content>
<ion-header-bar class="bar-positive">
<button class="button button-icon" ng-click="toggleLeft()" menu-toggle="left">
<i class="icon ion-navicon"></i>
</button>
<h1 class="title"> Details</h1>
</ion-header-bar>
</ion-side-menu-content>
<ion-side-menu side="left">
<header class="bar bar-header bar-assertive">
<h1 class="title">Menu</h1>
</header>
<ion-list>
<ion-item>
Home
</ion-item>
<ion-item>
About
</ion-item>
<ion-item>
Setting
</ion-item>
<ion-item>
Log out
</ion-item>
</ion-list>
</ion-side-menu>
</ion-side-menus>
<ion-content>
Hello World
</ion-content>
</ion-tab>
Here is my controller:
angular.module('app')
.controller('textController', function ($scope, $ionicSideMenuDelegate) {
$scope.toggleLeft = function () {
$ionicSideMenuDelegate.toggleLeft();
}
});
Following the official Ionic documentation (http://ionicframework.com/docs/guide/starting.html) it seems that your "Hello World" content should be inside a <ion-side-menu-content> tag, not a simple <ion-content>. Please try that and let me know if that solves your problem.
I got a design from client. I want to embed small icon inside my sidemenu.
My current code
<ion-side-menus>
<ion-pane ion-side-menu-content>
<ion-nav-bar class="bar-stable nav-title-slide-ios7">
<ion-nav-back-button class="button-clear"><i class="icon ion-ios7-arrow-back"></i> Back</ion-nav-back-button>
</ion-nav-bar>
<ion-nav-view name="menuContent" animation="slide-left-right"></ion-nav-view>
</ion-pane>
<ion-side-menu side="left">
<header class="bar bar-header bar-stable">
<h1 class="title">Menu</h1>
</header>
<ion-content class="has-header">
<ion-list>
<ion-item nav-clear menu-close href="#/app/home">
Home
</ion-item>
<ion-item nav-clear menu-close href="#/app/profile">
Profile
</ion-item>
<ion-item nav-clear menu-close href="#/app/friend">
Friends
</ion-item>
<ion-item nav-clear menu-close href="#/app/setting">
Setting
</ion-item>
<ion-item nav-clear menu-close href="#/app/shop">
Shop
</ion-item>
</ion-list>
</ion-content>
</ion-side-menu>
</ion-side-menus>
My objective
I already got the answer
<ion-side-menus>
<ion-pane ion-side-menu-content>
<ion-nav-bar class="bar-stable nav-title-slide-ios7">
<ion-nav-back-button class="button-clear"><i class="icon ion-ios7-arrow-back"></i> Back</ion-nav-back-button>
</ion-nav-bar>
<ion-nav-view name="menuContent" animation="slide-left-right"></ion-nav-view>
</ion-pane>
<ion-side-menu side="left">
<header class="bar bar-header bar-stable">
</header>
<ion-content class="has-header mymenu">
<ion-list>
<ion-item nav-clear menu-close href="#/app/home">
<img src="img/home.png" width="30" />Home </ion-item>
<ion-item nav-clear menu-close href="#/app/profile">
<img src="img/profile.png" width="30" />Profile </ion-item>
<ion-item nav-clear menu-close href="#/app/friend">
<img src="img/friend.png" width="30" ng-click="friend()"/>Friends
</ion-item>
<ion-item nav-clear menu-close href="#/app/setting">
<img src="img/setting.png" width="30" />Setting
</ion-item>
<ion-item nav-clear menu-close href="#/app/shop">
<img src="img/shop.png" width="30" ng-click="shop()"/>Shop
</ion-item>
</ion-list>
</ion-content>
</ion-side-menu>
</ion-side-menus>
All you have to do is add the icon that you want in the same as the text. Here is an example: http://plnkr.co/edit/KIErTU?p=preview
<ion-item>
<i class='ion-checkmark-circled'></i>home
</ion-item>
Nothing pretty, but it shows the point.
<ion-item menu-close class="item-icon-left">
<i class="icon ion-home" ></i>
Home
</ion-item>
Add class item-icon-leftto ion-item to nicely style and align the icons.
Here is How You can so it while keeping ionic sidemenu intact.
This is for ionic 2:-
app.component.js
pages: Array<{
title: string,
component: any ,
icon: string,
class: string
}>;
constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen) {
this.initializeApp();
// used for an example of ngFor and navigation
this.pages = [
{
title: 'Home',
component: HomePage ,
icon: '<i class="fa fa-pencil"></i>' ,
class: 'class1'
},
{
title: 'List',
component: ListPage ,
icon: '<i class="fa fa-plus"></i>' ,
class: 'class2'
},
{
title: 'Login Page',
component: LoginPage ,
icon: '<i class="fa fa-book"></i>' ,
class: 'class3'
}
];
}
app.html:-
<ion-content>
<ion-list>
<button [ngClass]="p.class" menuClose ion-item *ngFor="let p of pages" (click)="openPage(p)">
<span class="menu_item_icon" [innerHTML]="p.icon"></span>
<span class="menu_item_title">
{{p.title}}
</span>
</button>
</ion-list>
</ion-content>
I used the ionic default boilerplate that contains the sidemenu.
Am new to Angular2. But I like doing things the clean way.
You could use what Afflicted suggested but the following solution I used has a correct outlining:
<div class="list">
<a class="item item-icon-left" href="#">
<i class="icon ion-email"></i>
Check mail
</a>
...
List icons in ionic