Ionic name name does not work

I am following some examples from a 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 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 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 states that view-title = "Test" should fill out the title in ion-navbar. But it doesn't seem to work. Does anyone know what is going wrong?

+5
source share
4 answers

It looks like it can be used in both directions,

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

or

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

according to the latest version of ionic. http://ionicframework.com/docs/api/directive/ionView/ http://ionicframework.com/docs/api/directive/ionNavTitle/

+17
source

That should work

 <ion-view> <ion-nav-title> Your title here </ion-nav-title> </ion-view> 
+5
source

Switch to <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

+1
source

Ionic is constantly working, and they will update the directives in future releases, and I assume that you are using the old version.

According to doc 1.0.0-beta.13 , the attribute should be title instead of view-title

Change the following line

 <ion-view view-title="Home"> 

to

 <ion-view title="Home"> 

Old version of Doc: http://ionicframework.com/docs/1.0.0-beta.13/api/directive/ionView/

But in the latest version it should be view-title

Latest document: http://ionicframework.com/docs/api/directive/ionView/

-3
source

Source: https://habr.com/ru/post/1207396/


All Articles