This commit is contained in:
Max Lynch
2013-12-04 15:55:53 -06:00
parent 4c0e82e782
commit a83b57305f
5 changed files with 42 additions and 5 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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');
}

View File

@@ -39,7 +39,7 @@
</tab>
<!-- Adoption tab -->
<tab title="Adopt" icon="icon ion-heart" ng-controller="AdoptCtrl" right-buttons="buttons">
<tab title="Adopt" icon="icon ion-heart" ng-controller="AdoptCtrl" left-buttons="leftButtons" right-buttons="buttons">
<content has-header="true" has-tabs="true">
<div class="padding">
<h2>Adopt a pet today.</h2>

View File

@@ -21,7 +21,7 @@
</pane>
<script id="page1.html" type="text/ng-template">
<nav-page title="'Bears'" hide-back-button="true">
<nav-page title="'Bears'" hide-back-button="true" right-buttons="rightButtons">
<content has-header="true">
<h1>Page 1</h1>
<span>{{num}}</span>
@@ -76,6 +76,15 @@
.controller('Page1Ctrl', function($scope) {
$scope.num = Math.floor(Math.random() * 100);
$scope.rightButtons = [
{
text: 'Hello',
click: function(e) {
console.log('Click button');
}
}
]
});