Hello, Is there any way we can alight title to left. I need to add more icons to right.
<ion-view title="Schedule" ng-controller="scheduleDay as vm" hide-back-button="true">
<ion-nav-buttons side="left">
<a class="button button-clear button-icon icon ion-chevron-left" ui-sref="app.home"></a>
<button class="button button-icon icon ion-grid" ng-click="vm.goToScheduleAgenda()"></button>
</ion-nav-buttons>
<ion-nav-buttons side="right">
<button class="button button-icon icon ion-map" ng-click="vm.goToScheduleMap()"></button>
<button class="button button-icon icon ion-plus-round" ng-show="vm.canScheduleMeeting()" ng-click="vm.scheduleMeeting()"></button>
</ion-nav-buttons>
sjerd
December 17, 2014, 12:05pm
2
Add this to your .config
sample code:
ionicApp.config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) {
$ionicConfigProvider.navBar.alignTitle('left')
});
4 Likes
This might align title to left for all screens. I should align for only specific screens.
Any help?
1 Like
I tried but it was not taking effect. When I added inside my controller it is not taking effect. (I injected $ionicNavBarDelegate to my controller.)
Here is my controller
function login($state, $stateParams, $ionicLoading, $cordovaDialogs, claimsApi, cacheService, initialDataService, photoManagerService,$ionicNavBarDelegate) {
activate();
function activate() {
$ionicNavBarDelegate.align('left');}
}
Actually here is how I implement my screens. Is there any thing I am missing here?
In index.html
<ion-side-menu-content>
<!--This pane is main window for entire application-->
<ion-nav-bar class="bar-positive nav-title-slide-ios7" align-title="left">
<ion-nav-back-button class="button-clear"><i class="icon ion-chevron-left"></i> </ion-nav-back-button>
</ion-nav-bar>
<ion-nav-view name="menuContent" animation="slide-left-right"></ion-nav-view>
</ion-side-menu-content>
In each screen
<ion-view title="Schedule" ng-controller="scheduleDay as vm" hide-back-button="true">
<ion-nav-buttons side="left">
<a class="button button-clear button-icon icon ion-chevron-left" ui-sref="app.home"></a>
<button class="button button-icon icon ion-grid" ng-click="vm.goToScheduleAgenda()"></button>
</ion-nav-buttons>
<ion-nav-buttons side="right">
<button class="button button-icon icon ion-map" ng-click="vm.goToScheduleMap()"></button>
<button class="button button-icon icon ion-plus-round" ng-show="vm.canScheduleMeeting()" ng-click="vm.scheduleMeeting()"></button>
</ion-nav-buttons>
mladen5
January 15, 2015, 11:21am
6
$ionicNavBarDelegate.align(âcenterâ); in my controller also doesnât work. Even if i change align-title of ion-header-bar it still doesnât change.
zaher
January 15, 2015, 12:08pm
7
have you tried to set it up in your .config ?
.config(function( $ionicConfigProvider) {
$ionicConfigProvider.navBar.alignTitle('center');
});
this worked for me
1 Like
Add the align-title=âcenterâ attribute in your ion-nav-bar
<ion-nav-bar class="..." align-title="left">
...
</ion-nav-bar>
2 Likes
I found this works for me. I needed to dynamically change the title alignment per controller:
$scope.$on('$ionicView.enter', function()
{
$timeout(function()
{
$ionicNavBarDelegate.align('left');
});
});
2 Likes
grege
January 20, 2016, 9:25am
10
@Greycloak 's solution was the only thing that worked for me.
Thanks @Greycloak , itâs working for me as well
soal
July 19, 2016, 12:36pm
12
thanks this worked for my project
Thanks a lot. This works . I was able to set alignment of my title to Center using using this.
With this approach, during the development time, I can see the title moving from right to center; but when I deploy the app to a device, it works perfectly. Thanks.