Below are my HTML code which am using to enable side menu using ionic framework
<ion-side-menus enable-menu-with-back-views="false">
<ion-side-menu-content>
<ion-nav-bar class="bar bar-header bar-custom">
<ion-nav-buttons side="left">
<button class="button button-icon button-clear ion-navicon" menu-toggle="left"> </button>
</ion-nav-buttons>
<ion-nav-back-button class="button-clear" ng-click="myGoBack()"> <i class="ion-arrow-left-c"></i> </ion-nav-back-button>
</ion-nav-bar>
<ion-nav-view cache-view="false" class="roAppStyle" name="menuContent"></ion-nav-view>
</ion-side-menu-content>
<ion-side-menu side="left" expose-aside-when="large">
<ion-header-bar class="bar-stable">
<h1 class="title item-icon-left "> <i class="icon ion-person"></i>{{user.name}} </h1> </ion-header-bar>
<ion-content>
<ion-list>
<ion-item ng-repeat="menu in sideMenuList" class="item item-icon-left" menu-close ng-click={{menu.method}}> <i class={{menu.icon}}></i> {{menu.label}} </ion-item>
<!-- <ion-item class="item item-icon-left" menu-close ui-sref="app.home"> <i class="icon ion-ios-home"></i> Home </ion-item> <ion-item class="item item-icon-left" menu-close ng-click="goToProducts()" > <i class="icon ion-egg"></i> Products </ion-item> <ion-item class="item item-icon-left" menu-close ng-click="goToOrder()" > <i class="icon ion-android-cart"></i> Order </ion-item> <ion-item class="item item-icon-left" menu-close ng-click="goToDeliveryAgent()" > <i class="icon ion-android-person"></i> Delivery Agent </ion-item> <ion-item class="item item-icon-left" menu-close ng-click="goToOffers()" > <i class="icon ion-pricetags"></i> Offers </ion-item> -->
<!-- <ion-item menu-close class="item item-icon-left" ui-sref="app.offers"> <i class="icon ion-pricetags"></i> Offers </ion-item> -->
<ion-item class="item item-icon-left" ng-click="exitTheApp()"> <i class="icon ion-log-out"></i> Exit </ion-item>
</ion-list>
</ion-content>
</ion-side-menu>
</ion-side-menus>
Client code:
app.controller('appCtrl', function($scope, $state, baseConstant, $ionicHistory, $ionicPopup, $rootScope, angularService, webSocketConnection) {
$scope.goToProducts = function() {
$state.go('app.product');
}
$scope.goToDeliveryAgent = function() {
$state.go('app.deliveryAgent');
}
$scope.goToOffers = function() {
$state.go('app.offers');
}
$scope.goToOrder = function() {
$state.go('app.order');
}
$scope.goToDeliveryAcceptedOrder = function() {
$state.go('app.deliveryacceptedOrders');
}
$scope.goToDeliveryCancelOrder = function() {
$state.go('app.deliveryCancelOrders');
}
if ($rootScope.user.type === baseConstant.RO_USER_TYPE) {
$scope.sideMenuList = baseConstant.roUserMenus;
$state.go("app.product");
}
else if ($rootScope.user.type === baseConstant.DELIVERY_USER_TYPE) {
$scope.sideMenuList = baseConstant.deliveryUserMenus;
$state.go("app.deliveryacceptedOrders");
}
$scope.myGoBack = function() {
$ionicHistory.goBack();
};
$scope.exitTheApp = function() {
var confirmPopup = $ionicPopup.confirm({
title: 'Alert',
template: 'Are you sure you want to exit the app..?'
});
confirmPopup.then(function(res) {
if (res) {
var socketConnection = webSocketConnection.getWebSocketConnection(baseConstant.OFFLINE);
navigator.app.exitApp();
}
});
}
$scope.imageUrl = baseConstant.IMAGE_URL;
});
when it is ro user the first screen of ro user has menu button but when i register as delivery user the first screen of delivery user has back button.i want side menu button
Related
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>
When I refer the item individualy on angularJS it works fine, but in collection not work.
This colletcion not working in my ionic project, anyone knows what is wrong ?? thanks !
//JavaScript part
//HTML part
MapApp.controller('MenuCtrl', function($scope) {
$scope.itens = [
{titulo: 'Mapa'},
{titulo: 'Login'},
{titulo: 'Sobre'}
];
$scope.TituloMenu = 'Menu';
//$scope.currItens = $scope.itens;
});
<!-- NOT WORK -->
<ion-item nav-clear menu-close href="#/map/login"
collection-item-height="52" collection-repeat"item in itens" class="item item-icon-left"
item-height="250" item-width="100%">
<i class="icon ion-chevron-right"></i>{{item.titulo}}
</ion-item>
<!-- IT WORK -->
<ion-item nav-clear menu-close href="#/map/login" class="item item-icon-left" >
<i class="icon ion-ios-arrow-right"></i>{{itens[0].titulo}}
</ion-item>
<ion-item nav-clear menu-close href="#/map/login" class="item item-icon-left" >
<i class="icon ion-ios-arrow-right"></i>{{itens[1].titulo}}
</ion-item>
<ion-item nav-clear menu-close href="#/map/login" class="item item-icon-left" >
<i class="icon ion-ios-arrow-right"></i>{{itens[2].titulo}}
</ion-item>
You are missing an equals sign in the html.
collection-repeat"item in itens"
collection-repeat="item in itens"
I'm writing a small ionic app and have an issue. I'm using a sidemenu and also tabs. I have an ionic slide-box in one of my views, when I wipe this slidebox from left to right the side menu slides out. I've read through various related topics on the ionic forum but none have worked.
I've tried adding drag-content="false" to various tags and also added $ionicSideMenuDelegate.canDragContent(false); to my controller.
Neither worked. I think it's because I'm using a sidemenu, with tabs and views in the tabs. Heres my code:
index.html
<ion-side-menus>
<!-- Header bar -->
<ion-side-menu-content ng-controller="NavCtrl" drag-content="false">
<ion-nav-bar class="bar-positive">
<ion-nav-back-button class="button-icon ion-ios7-arrow-back">
</ion-nav-back-button>
</ion-nav-bar>
<!-- Page content -->
<ion-nav-view drag-content="false" animation="slide-left-right"></ion-nav-view>
</ion-side-menu-content>
<!-- Side menu -->
<ion-side-menu side="left" class="side-menu">
<ion-header-bar class="bar bar-header bar-dark">
<h1 class="title">Menu</h1>
</ion-header-bar>
<ion-content has-header="true">
<div ng-if="authData.twitter" class="logged-in-user item item-avatar">
<img ng-src="{{authData.twitter.cachedUserProfile.profile_image_url}}"/>
<h2>Hello, {{authData.twitter.displayName}}</h2>
<p>Logged in via Twitter</p>
</div>
<div ng-if="authData.facebook" class="logged-in-user item item-avatar">
<img ng-src="{{authData.facebook.cachedUserProfile.picture.data.url}}"/>
<h2>Hello, {{authData.facebook.displayName}}</h2>
<p>Logged in via Facebook</p>
</div>
<ul class="list">
<li>
<a class="item item-icon-left" menu-close nav-clear href="#/venue">
<i class="icon ion-ios7-location"></i>Venue
</a>
</li>
<li>
<a class="item item-icon-left" menu-close nav-clear href="#/lunch">
<i class="icon ion-pizza"></i>Lunch
</a>
</li>
<li>
<a class="item item-icon-left" menu-close nav-clear href="#/wifi">
<i class="icon ion-wifi"></i>Wifi
</a>
</li>
</ul>
</ion-content>
<ion-footer-bar class="bar bar-dark">
<button class="button button-icon icon ion-log-out menu-close nav-clear" ng-controller="LoginCtrl" ng-click="logout()"> Logout</button>
</ion-footer-bar>
</ion-side-menu>
</ion-side-menus>
and my view:
<ion-view title="Agenda">
<ion-content drag-content="false">
<ion-slide-box on-slide-changed="slideHasChanged($index)">
<ion-slide>
<div class="header-card header-card--image">
<div class="overlay">
<div class="item item-text-wrap">
<h3 class="header-card__heading">Happening now</h3>
<img ng-src="img/me.jpeg" class="header-card__avatar"/>
<h2 class="header-card__heading">some guy</h2>
<p class="header-card__text">Some title</p>
</div>
</div>
</div>
</ion-slide>
<ion-slide>
<div class="header-card header-card--image">
<div class="overlay">
<div class="item item-text-wrap">
<h3 class="header-card__heading">Coming Next</h3>
<img ng-src="img/me.jpeg" class="header-card__avatar"/>
<h2 class="header-card__heading">Some guy</h2>
<p class="header-card__text">Slowly taking over the world</p>
</div>
</div>
</div>
</ion-slide>
</ion-slide-box>
<ion-list>
<ion-item ng-repeat="(id,agendaItem) in agendaItems" type="item-text-wrap" href="#/tab/agendaItem/{{agendaItem.$id}}" class="item item-avatar item-with-grid">
<img ng-src="{{agendaItem.image}}">
<p>{{agendaItem.startTime}} <i ng-if="agendaItem.hasNotificationSet == true" class="icon-left ion-ios7-bell"></i></p>
<h2>{{agendaItem.title}}</h2>
<p>{{agendaItem.speaker}}</p>
<ion-option-button ng-class="agendaItem.hasNotificationSet ? 'button-balanced icon ion-ios7-bell' : 'button-positive icon ion-ios7-bell-outline'" ng-controller="NotificationCtrl" ng-click="add(agendaItem)"></ion-option-button>
<!--<ion-option-button ng-click="getNotificationIds()"></ion-option-button>-->
</ion-item>
</ion-list>
</ion-content>
and my controller:
.controller('AgendaCtrl', function($scope, AgendaFactory, $ionicSideMenuDelegate, $rootScope, $ionicPopup, $timeout, $cordovaLocalNotification, NotificationFactory) {
$ionicSideMenuDelegate.canDragContent(false); // doesn't seem to work
var agendaItems = AgendaFactory.getAgenda();
// Loop through agenda itens and check which have notifications set
agendaItems.$loaded().then(function(array) {
angular.forEach(array, function(value, key) {
if (NotificationFactory.isNotificationScheduled(value.notificationId) == true) {
value.hasNotificationSet = true;
} else {
value.hasNotificationSet = false;
}
});
$scope.getNotificationIds = function () {
$cordovaLocalNotification.getScheduledIds().then(function (scheduledIds) {
console.log(scheduledIds);
});
};
$scope.agendaItems = agendaItems;
});
$scope.firstTimeLogin = $rootScope.firstTimeLogin;
})
I'm using something like this on my app:
.controller('AgendaCtrl', function($scope, $ionicSideMenuDelegate){
$scope.$on('$ionicView.enter', function(){
$ionicSideMenuDelegate.canDragContent(false);
});
$scope.$on('$ionicView.leave', function(){
$ionicSideMenuDelegate.canDragContent(true);
});
})
now, when you leave the view it's draggable again.
ion-side-menu-content drag-content="false" put this code in your ion-sidemenu's ion-pane tag
<ion-side-menus>
<ion-side-menu-content drag-content="false">
............
</ion-side-menu-content>
</ion-side-menus>
this is sample code follow #Chetan Buddh's answer
Here is my link http://codepen.io/sanand29/pen/mKkvw
<html ng-app="ionicApp">
<title>Ionic Template</title>
<link href="http://code.ionicframework.com/1.0.0-beta.8/css/ionic.css" rel="stylesheet">
<script src="http://code.ionicframework.com/1.0.0-beta.8/js/ionic.bundle.js"></script>
</head>
<body ng-controller="MyCtrl">
<ion-view class="pane"></ion-view>
<ion-side-menus>
<ion-side-menu-content>
<ion-header-bar class="bar-positive">
<button class="button button-icon icon ion-navicon-round"
menu-toggle="left"
></button>
<h1 class="title">Welcome</h1>
</ion-header-bar>
<ion-list>
<ion-item href="#/tab/admission-information" class="item item-icon-right ">
Admission-Information
<i class="icon ion-chevron-right icon-accessory"></i>
</ion-item>
<ion-item href="#/tab/contacts" class="item item-icon-right ">
Contacts
<i class="icon ion-chevron-right icon-accessory"></i>
</ion-item>
<ion-item href="#/tab/program-details" class="item item-icon-right ">
Program details
<i class="icon ion-chevron-right icon-accessory"></i>
</ion-item>
<ion-item href="#/tab/tution-fees" class="item item-icon-right ">
Tution fees
<i class="icon ion-chevron-right icon-accessory"></i>
</ion-item>
<ion-item href="#/tab/financial-aids" class="item item-icon-right ">
Financial Aids
<i class="icon ion-chevron-right icon-accessory"></i>
</ion-item>
<ion-item href="#/tab/faqs" class="item item-icon-right ">
FAQs
<i class="icon ion-chevron-right icon-accessory"></i>
</ion-item>
</ion-list>
</ion-side-menu-content>
<ion-side-menu side="left">
<ion-header-bar class="bar-assertive">
<h1 class="title">Left menu</h1>
</ion-header-bar>
</ion-side-menu>
</ion-side-menus>
<script type="text/javascript">
angular.module('ionicApp', ['ionic'])
.controller('MyCtrl', function($scope) {
});</script>
the navigation bars that i have given, on clicking them its not sliding from left to right. I have given the slider class correctly i think,,I can't find out my fault. Kindly show in fiddle or code pen. Any help would be appreciated
If you want to get the view to slide in when a tab is clicked you should use an animation class on an ion-nav-view.
If you want to get the view to slide in when the user slides across the view you should use an ion-slide-box
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