mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
Merge pull request #501 from uniring/nav-bar-title
Allows a view to update the navbar title if his title changes
This commit is contained in:
10
js/ext/angular/src/directive/ionicViewState.js
vendored
10
js/ext/angular/src/directive/ionicViewState.js
vendored
@@ -137,6 +137,10 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
|
||||
updateHeaderData(data);
|
||||
});
|
||||
|
||||
$rootScope.$on('viewState.titleUpdated', function(e, data) {
|
||||
$scope.currentTitle = (data && data.title ? data.title : '');
|
||||
});
|
||||
|
||||
// If a nav page changes the left or right buttons, update our scope vars
|
||||
$scope.$parent.$on('viewState.leftButtonsChanged', function(e, data) {
|
||||
$scope.leftButtons = data;
|
||||
@@ -198,10 +202,16 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
|
||||
$scope.$emit('viewState.rightButtonsChanged', $scope.rightButtons);
|
||||
});
|
||||
|
||||
// watch for changes in the title
|
||||
var deregTitle = $scope.$watch('title', function(val) {
|
||||
$scope.$emit('viewState.titleUpdated', $scope);
|
||||
});
|
||||
|
||||
$scope.$on('$destroy', function(){
|
||||
// deregister on destroy
|
||||
deregLeftButtons();
|
||||
deregRightButtons();
|
||||
deregTitle();
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user