From a83b57305fe2fda784ec959d9328918d30d96da9 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Wed, 4 Dec 2013 15:55:53 -0600 Subject: [PATCH] Fixed #254 --- dist/js/ionic-angular.js | 12 +++++++++++- js/ext/angular/src/directive/ionicNavRouter.js | 12 +++++++++++- js/ext/angular/test/header.html | 10 +++++++++- js/ext/angular/test/navAndTabs.html | 2 +- js/ext/angular/test/navRouter.html | 11 ++++++++++- 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/dist/js/ionic-angular.js b/dist/js/ionic-angular.js index f49ebce951..6c2961d100 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 d460aa4bc8..e28da6622b 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 823ba5bf47..defed03656 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 eb6dd89c03..45ef7d06e5 100644 --- a/js/ext/angular/test/navAndTabs.html +++ b/js/ext/angular/test/navAndTabs.html @@ -39,7 +39,7 @@ - +

Adopt a pet today.

diff --git a/js/ext/angular/test/navRouter.html b/js/ext/angular/test/navRouter.html index 2f277ac609..9fc05c3c3d 100644 --- a/js/ext/angular/test/navRouter.html +++ b/js/ext/angular/test/navRouter.html @@ -21,7 +21,7 @@