Issue updating an ion-view title


#1

I kinda know why this is happening but I’m having difficulty actually fixing it. :wink:

I’ve got a view using this:

<ion-view title="{{entry.title}}">

In my controller, I load an entry asynchronously like so:

.controller('EntryCtrl', ['$scope', 'RSSService', '$stateParams', function($scope, RSSService, $stateParams) {

RSSService.getEntry($stateParams.index).then(function(entry) {
	$scope.entry = entry;
}, function(err) {
	console.log("error", err);
});

}]);

I’ve tried $scope.$apply but get the digest already in progress error.


#2

can you create a code pen Raymond. Wan to try one or 2 things


#3

FYI, I see that the attribute is now view-title, but using that didn’t help.


#4

It has a lot of files currently - would you mind a zip?


#5

Ah I ran across this the other day and was going to do some more tests before putting in a PR.
Try using the ionic-title directive instead of the attribute in the view.


Title from ion-nav-view is missing sometimes
#6

Hi todd the attribute has now changed since beta 13 I think to view-title


#7

Yeah, I tried view-title, but it didn’t help.


#8

Yes, I know that there have been changes, but I too was having trouble updating the title. In the end, to get it updating I had to use the title directive (can’t remember the actual name just now) instead of using the attribute in the view directive.

I’m mobile now but can post some code later today if it’s still not clear.


#9

Ok folks, thanks to Todd I checked out ion-nav-title:

<ion-view view-title="{{entry.title}}">
<ion-nav-title>{{entry.title}}</ion-nav-title>

Yes, I know I have the title duplicated there, will fix later. :wink: This works, but the title is horribly cropped:

It is virtually unusable like this. Am I using it wrong?


#10

Ah yes, it’s ion-nav-title. http://ionicframework.com/docs/api/directive/ionNavTitle/
Using this got it working for me.


View-title not updated after scope apply
#11

Ok, looks to be a known bug, https://github.com/driftyco/ionic/issues/2945.


#12

Applying this change It works fine!

Instead of

<ion-view title='{{datos.titulo}}' cache-view="false">

use

<ion-view cache-view="false">
<ion-nav-title>{{datos.titulo}}</ion-nav-title>
</ion-view>

#14

For anyone interested I wrote up my findings on this in a quick blog post, including a couple of codepens.


#15

Thanks for taking the time to research and document this.