From 12e5f6c1162adc1094026c5539932a66f5767fb9 Mon Sep 17 00:00:00 2001 From: Andy Joslin Date: Tue, 29 Apr 2014 06:09:34 -0600 Subject: [PATCH] fix(ionView): only $watch attributes if defined Closes #1216 --- js/angular/directive/view.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/js/angular/directive/view.js b/js/angular/directive/view.js index 7721c54b4ea..bf39433556f 100644 --- a/js/angular/directive/view.js +++ b/js/angular/directive/view.js @@ -59,15 +59,19 @@ IonicModule } - $scope.$watch($attr.hideBackButton, function(value) { - // Should we hide a back button when this tab is shown - navBarCtrl.showBackButton(!value); - }); + if (angular.isDefined($attr.hideBackButton)) { + $scope.$watch($attr.hideBackButton, function(value) { + // Should we hide a back button when this tab is shown + navBarCtrl.showBackButton(!value); + }); + } - $scope.$watch($attr.hideNavBar, function(value) { - // Should the nav bar be hidden for this view or not? - navBarCtrl.showBar(!value); - }); + if (angular.isDefined($attr.hideNavBar)) { + $scope.$watch($attr.hideNavBar, function(value) { + // Should the nav bar be hidden for this view or not? + navBarCtrl.showBar(!value); + }); + } }; }