Skip to content

Commit a83b573

Browse files
committed
Fixed #254
1 parent 4c0e82e commit a83b573

File tree

5 files changed

+42
-5
lines changed

5 files changed

+42
-5
lines changed

dist/js/ionic-angular.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,13 @@ angular.module('ionic.ui.navRouter', ['ionic.service.gesture'])
13111311
}
13121312
});
13131313

1314+
// If a nav page changes the left or right buttons, update our scope vars
1315+
$scope.$parent.$on('navRouter.leftButtonsChanged', function(e, data) {
1316+
$scope.leftButtons = data;
1317+
});
1318+
$scope.$parent.$on('navRouter.rightButtonsChanged', function(e, data) {
1319+
$scope.rightButtons = data;
1320+
});
13141321

13151322
/*
13161323
$scope.$parent.$on('navigation.push', function() {
@@ -1361,14 +1368,17 @@ angular.module('ionic.ui.navRouter', ['ionic.service.gesture'])
13611368
$scope.$watch(leftButtonsGet, function(value) {
13621369
$scope.leftButtons = value;
13631370
if($scope.doesUpdateNavRouter) {
1364-
$scope.$emit('navRouter.leftButtonsChanged', $scope.rightButtons);
1371+
$scope.$emit('navRouter.leftButtonsChanged', $scope.leftButtons);
13651372
}
13661373
});
13671374

13681375
// watch for changes in the right buttons
13691376
var rightButtonsGet = $parse($attr.rightButtons);
13701377
$scope.$watch(rightButtonsGet, function(value) {
13711378
$scope.rightButtons = value;
1379+
if($scope.doesUpdateNavRouter) {
1380+
$scope.$emit('navRouter.rightButtonsChanged', $scope.rightButtons);
1381+
}
13721382
});
13731383

13741384
// watch for changes in the title

js/ext/angular/src/directive/ionicNavRouter.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,13 @@ angular.module('ionic.ui.navRouter', ['ionic.service.gesture'])
283283
}
284284
});
285285

286+
// If a nav page changes the left or right buttons, update our scope vars
287+
$scope.$parent.$on('navRouter.leftButtonsChanged', function(e, data) {
288+
$scope.leftButtons = data;
289+
});
290+
$scope.$parent.$on('navRouter.rightButtonsChanged', function(e, data) {
291+
$scope.rightButtons = data;
292+
});
286293

287294
/*
288295
$scope.$parent.$on('navigation.push', function() {
@@ -333,14 +340,17 @@ angular.module('ionic.ui.navRouter', ['ionic.service.gesture'])
333340
$scope.$watch(leftButtonsGet, function(value) {
334341
$scope.leftButtons = value;
335342
if($scope.doesUpdateNavRouter) {
336-
$scope.$emit('navRouter.leftButtonsChanged', $scope.rightButtons);
343+
$scope.$emit('navRouter.leftButtonsChanged', $scope.leftButtons);
337344
}
338345
});
339346

340347
// watch for changes in the right buttons
341348
var rightButtonsGet = $parse($attr.rightButtons);
342349
$scope.$watch(rightButtonsGet, function(value) {
343350
$scope.rightButtons = value;
351+
if($scope.doesUpdateNavRouter) {
352+
$scope.$emit('navRouter.rightButtonsChanged', $scope.rightButtons);
353+
}
344354
});
345355

346356
// watch for changes in the title

js/ext/angular/test/header.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@
3131
$scope.headerTitle = 'A really really really really really long title here';
3232
$scope.leftButtons = [
3333
{
34-
text: 'Hello',
34+
content: 'Hello',
35+
click: function(e) {
36+
console.log('Click button');
37+
}
38+
}
39+
]
40+
$scope.rightButtons = [
41+
{
42+
content: 'Hello',
3543
click: function(e) {
3644
console.log('Click button');
3745
}

js/ext/angular/test/navAndTabs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ <h3>{{pet.title}}</h3>
3939
</tab>
4040

4141
<!-- Adoption tab -->
42-
<tab title="Adopt" icon="icon ion-heart" ng-controller="AdoptCtrl" right-buttons="buttons">
42+
<tab title="Adopt" icon="icon ion-heart" ng-controller="AdoptCtrl" left-buttons="leftButtons" right-buttons="buttons">
4343
<content has-header="true" has-tabs="true">
4444
<div class="padding">
4545
<h2>Adopt a pet today.</h2>

js/ext/angular/test/navRouter.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</pane>
2222

2323
<script id="page1.html" type="text/ng-template">
24-
<nav-page title="'Bears'" hide-back-button="true">
24+
<nav-page title="'Bears'" hide-back-button="true" right-buttons="rightButtons">
2525
<content has-header="true">
2626
<h1>Page 1</h1>
2727
<span>{{num}}</span>
@@ -76,6 +76,15 @@ <h1>Page 3</h1>
7676

7777
.controller('Page1Ctrl', function($scope) {
7878
$scope.num = Math.floor(Math.random() * 100);
79+
80+
$scope.rightButtons = [
81+
{
82+
text: 'Hello',
83+
click: function(e) {
84+
console.log('Click button');
85+
}
86+
}
87+
]
7988
});
8089

8190

0 commit comments

Comments
 (0)