diff --git a/dist/js/ionic-angular.js b/dist/js/ionic-angular.js index f49ebce951b..6c2961d1004 100644 --- a/dist/js/ionic-angular.js +++ b/dist/js/ionic-angular.js @@ -1311,6 +1311,13 @@ angular.module('ionic.ui.navRouter', ['ionic.service.gesture']) } }); + // If a nav page changes the left or right buttons, update our scope vars + $scope.$parent.$on('navRouter.leftButtonsChanged', function(e, data) { + $scope.leftButtons = data; + }); + $scope.$parent.$on('navRouter.rightButtonsChanged', function(e, data) { + $scope.rightButtons = data; + }); /* $scope.$parent.$on('navigation.push', function() { @@ -1361,7 +1368,7 @@ angular.module('ionic.ui.navRouter', ['ionic.service.gesture']) $scope.$watch(leftButtonsGet, function(value) { $scope.leftButtons = value; if($scope.doesUpdateNavRouter) { - $scope.$emit('navRouter.leftButtonsChanged', $scope.rightButtons); + $scope.$emit('navRouter.leftButtonsChanged', $scope.leftButtons); } }); @@ -1369,6 +1376,9 @@ angular.module('ionic.ui.navRouter', ['ionic.service.gesture']) var rightButtonsGet = $parse($attr.rightButtons); $scope.$watch(rightButtonsGet, function(value) { $scope.rightButtons = value; + if($scope.doesUpdateNavRouter) { + $scope.$emit('navRouter.rightButtonsChanged', $scope.rightButtons); + } }); // watch for changes in the title diff --git a/js/ext/angular/src/directive/ionicNavRouter.js b/js/ext/angular/src/directive/ionicNavRouter.js index d460aa4bc89..e28da6622b6 100644 --- a/js/ext/angular/src/directive/ionicNavRouter.js +++ b/js/ext/angular/src/directive/ionicNavRouter.js @@ -283,6 +283,13 @@ angular.module('ionic.ui.navRouter', ['ionic.service.gesture']) } }); + // If a nav page changes the left or right buttons, update our scope vars + $scope.$parent.$on('navRouter.leftButtonsChanged', function(e, data) { + $scope.leftButtons = data; + }); + $scope.$parent.$on('navRouter.rightButtonsChanged', function(e, data) { + $scope.rightButtons = data; + }); /* $scope.$parent.$on('navigation.push', function() { @@ -333,7 +340,7 @@ angular.module('ionic.ui.navRouter', ['ionic.service.gesture']) $scope.$watch(leftButtonsGet, function(value) { $scope.leftButtons = value; if($scope.doesUpdateNavRouter) { - $scope.$emit('navRouter.leftButtonsChanged', $scope.rightButtons); + $scope.$emit('navRouter.leftButtonsChanged', $scope.leftButtons); } }); @@ -341,6 +348,9 @@ angular.module('ionic.ui.navRouter', ['ionic.service.gesture']) var rightButtonsGet = $parse($attr.rightButtons); $scope.$watch(rightButtonsGet, function(value) { $scope.rightButtons = value; + if($scope.doesUpdateNavRouter) { + $scope.$emit('navRouter.rightButtonsChanged', $scope.rightButtons); + } }); // watch for changes in the title diff --git a/js/ext/angular/test/header.html b/js/ext/angular/test/header.html index 823ba5bf476..defed036565 100644 --- a/js/ext/angular/test/header.html +++ b/js/ext/angular/test/header.html @@ -31,7 +31,15 @@ $scope.headerTitle = 'A really really really really really long title here'; $scope.leftButtons = [ { - text: 'Hello', + content: 'Hello', + click: function(e) { + console.log('Click button'); + } + } + ] + $scope.rightButtons = [ + { + content: 'Hello', click: function(e) { console.log('Click button'); } diff --git a/js/ext/angular/test/navAndTabs.html b/js/ext/angular/test/navAndTabs.html index eb6dd89c032..45ef7d06e55 100644 --- a/js/ext/angular/test/navAndTabs.html +++ b/js/ext/angular/test/navAndTabs.html @@ -39,7 +39,7 @@