Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic - ion-view title not working

I'm following some of the examples from the website and my current html is:

<!DOCTYPE html>
<html ng-app="Test">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/ionic.app.css" rel="stylesheet">
    -->

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>

    <!-- cordova script (this will be a 404 during development) -->
    <script src="cordova.js"></script>

    <!-- your app's js -->
    <script src="js/app.js"></script>
</head>

<body>
    <ion-nav-bar class="bar-positive">
        <ion-nav-back-button class="button-icon ion-arrow-left-c">
        </ion-nav-back-button>
    </ion-nav-bar>
    <ion-nav-view>
        <!-- Center content -->
    </ion-nav-view>

    <script type="text/ng-template" id="main.html">
        <ion-view view-title="Home">
            <ion-content >
                <p>
                   Test
                </p>
            </ion-content>
        </ion-view>
    </script>
</body>

</html>

And the js:

var app = angular.module('Test', ['ionic']);

app.config(function($stateProvider, $urlRouterProvider) {
  $urlRouterProvider.otherwise('/')

  $stateProvider.state('index', {
    url: '/',
    templateUrl: 'main.html',
    controller: 'TestCtrl'

  })
})

app.controller('TestCtrl', function($scope) {

})

Now the documentation says the view-title="Test" should fill the title in ion-navbar. But it doesn't seem to work. Anyone knows what is going wrong?

like image 345
Julian Avatar asked Nov 21 '14 11:11

Julian


3 Answers

It appears that it can be used in both ways,

<ion-view view-title="My Page">

or

<ion-nav-title>
    {{page.title}}
</ion-nav-title>

as per latest version of ionic. http://ionicframework.com/docs/api/directive/ionView/ http://ionicframework.com/docs/api/directive/ionNavTitle/

like image 139
Shahroon Avatar answered Nov 15 '22 12:11

Shahroon


This should work,

<ion-view>
  <ion-nav-title> Your title here
  </ion-nav-title>
</ion-view>
like image 45
mahi Avatar answered Nov 15 '22 10:11

mahi


Switch to using <ion-nav-title>

<ion-view>
<ion-nav-title>{{navTitle}}</ion-nav-title>
<ion-content overflow-scroll="true" padding="true" class="has-header">
    <div>
        <p>The opening crawl would go here.</p>
    </div>
</ion-content>

click to read more

like image 43
BlessNeo Avatar answered Nov 15 '22 12:11

BlessNeo