@@ -1168,11 +1168,11 @@ angular.module('ionic.ui.navRouter', ['ionic.service.gesture'])
1168
1168
template : '<header class="bar bar-header nav-bar" ng-class="{invisible: !navController.navBar.isVisible}">' +
1169
1169
'<div class="buttons"> ' +
1170
1170
'<button nav-back class="button" ng-if="enableBackButton && showBackButton" ng-class="backButtonClass" ng-bind-html="backButtonLabel"></button>' +
1171
- '<button ng-click="button.tap($event)" ng-repeat="button in leftButtons" class="button {{button.type}}" ng-bind-html="button.content"></button>' +
1171
+ '<button ng-click="button.tap($event)" ng-repeat="button in leftButtons" class="button no-animation {{button.type}}" ng-bind-html="button.content"></button>' +
1172
1172
'</div>' +
1173
1173
'<h1 class="title" ng-bind="currentTitle"></h1>' +
1174
1174
'<div class="buttons" ng-if="rightButtons.length"> ' +
1175
- '<button ng-click="button.tap($event)" ng-repeat="button in rightButtons" class="button {{button.type}}" ng-bind-html="button.content"></button>' +
1175
+ '<button ng-click="button.tap($event)" ng-repeat="button in rightButtons" class="button no-animation {{button.type}}" ng-bind-html="button.content"></button>' +
1176
1176
'</div>' +
1177
1177
'</header>' ,
1178
1178
link : function ( $scope , $element , $attr , navCtrl ) {
@@ -1234,6 +1234,14 @@ angular.module('ionic.ui.navRouter', ['ionic.service.gesture'])
1234
1234
}
1235
1235
} ;
1236
1236
1237
+ $scope . $parent . $on ( 'navRouter.showBackButton' , function ( e , data ) {
1238
+ $scope . enableBackButton = true ;
1239
+ } ) ;
1240
+
1241
+ $scope . $parent . $on ( 'navRouter.hideBackButton' , function ( e , data ) {
1242
+ $scope . enableBackButton = false ;
1243
+ } ) ;
1244
+
1237
1245
// Listen for changes on title change, and update the title
1238
1246
$scope . $parent . $on ( 'navRouter.pageChanged' , function ( e , data ) {
1239
1247
updateHeaderData ( data ) ;
@@ -1289,57 +1297,67 @@ angular.module('ionic.ui.navRouter', ['ionic.service.gesture'])
1289
1297
. directive ( 'navPage' , [ '$parse' , function ( $parse ) {
1290
1298
return {
1291
1299
restrict : 'E' ,
1292
- scope : true ,
1293
1300
require : '^navRouter' ,
1301
+ scope : {
1302
+ leftButtons : '=' ,
1303
+ rightButtons : '=' ,
1304
+ title : '=' ,
1305
+ icon : '@' ,
1306
+ iconOn : '@' ,
1307
+ iconOff : '@' ,
1308
+ type : '@' ,
1309
+ alignTitle : '@' ,
1310
+ hideBackButton : '@' ,
1311
+ hideNavBar : '@' ,
1312
+ animate : '@' ,
1313
+ } ,
1294
1314
link : function ( $scope , $element , $attr , navCtrl ) {
1295
1315
$element . addClass ( 'pane' ) ;
1296
1316
1297
- $scope . icon = $attr . icon ;
1298
- $scope . iconOn = $attr . iconOn ;
1299
- $scope . iconOff = $attr . iconOff ;
1300
-
1301
1317
// Should we hide a back button when this tab is shown
1302
- $scope . hideBackButton = $scope . $eval ( $attr . hideBackButton ) ;
1318
+ $scope . hideBackButton = $scope . $eval ( $scope . hideBackButton ) ;
1303
1319
1304
- $scope . hideNavBar = $scope . $eval ( $attr . hideNavBar ) ;
1320
+ $scope . hideNavBar = $scope . $eval ( $scope . hideNavBar ) ;
1305
1321
1306
1322
navCtrl . navBar . isVisible = ! $scope . hideNavBar ;
1307
1323
1324
+ if ( $scope . hideBackButton === true ) {
1325
+ $scope . $emit ( 'navRouter.hideBackButton' ) ;
1326
+ } else {
1327
+ $scope . $emit ( 'navRouter.showBackButton' ) ;
1328
+ }
1329
+
1308
1330
// Whether we should animate on tab change, also impacts whether we
1309
1331
// tell any parent nav controller to animate
1310
- $scope . animate = $scope . $eval ( $attr . animate ) ;
1311
-
1312
- // Grab whether we should update any parent nav router on tab changes
1313
- $scope . doesUpdateNavRouter = $scope . $eval ( $attr . doesUpdateNavRouter ) || true ;
1332
+ $scope . animate = $scope . $eval ( $scope . animate ) ;
1333
+
1314
1334
1315
1335
// watch for changes in the left buttons
1316
- var leftButtonsGet = $parse ( $attr . leftButtons ) ;
1317
- $scope . $watch ( leftButtonsGet , function ( value ) {
1318
- $scope . leftButtons = value ;
1319
- if ( $scope . doesUpdateNavRouter ) {
1320
- $scope . $emit ( 'navRouter.leftButtonsChanged' , $scope . leftButtons ) ;
1321
- }
1336
+ $scope . $watch ( 'leftButtons' , function ( value ) {
1337
+ $scope . $emit ( 'navRouter.leftButtonsChanged' , $scope . leftButtons ) ;
1322
1338
} ) ;
1323
1339
1324
- // watch for changes in the right buttons
1325
- var rightButtonsGet = $parse ( $attr . rightButtons ) ;
1326
- $scope . $watch ( rightButtonsGet , function ( value ) {
1327
- $scope . rightButtons = value ;
1328
- if ( $scope . doesUpdateNavRouter ) {
1329
- $scope . $emit ( 'navRouter.rightButtonsChanged' , $scope . rightButtons ) ;
1340
+ $scope . $watch ( 'rightButtons' , function ( val ) {
1341
+ $scope . $emit ( 'navRouter.rightButtonsChanged' , $scope . rightButtons ) ;
1342
+ } ) ;
1343
+
1344
+ /*
1345
+ $scope.$watch('hideBackButton', function(value) {
1346
+ if(value === true) {
1347
+ navCtrl.hideBackButton();
1348
+ } else {
1349
+ navCtrl.showBackButton();
1330
1350
}
1331
1351
});
1352
+ */
1332
1353
1333
1354
// watch for changes in the title
1334
- var titleGet = $parse ( $attr . title ) ;
1335
- $scope . $watch ( titleGet , function ( value ) {
1336
- $scope . title = value ;
1355
+ $scope . $watch ( 'title' , function ( value ) {
1337
1356
$scope . $emit ( 'navRouter.titleChanged' , {
1338
1357
title : value ,
1339
1358
animate : $scope . animate
1340
1359
} ) ;
1341
1360
} ) ;
1342
-
1343
1361
}
1344
1362
} ;
1345
1363
} ] )
0 commit comments