diff --git a/hacking/NavAngular.js b/hacking/NavAngular.js index a8210f560d..0d7ad2806b 100644 --- a/hacking/NavAngular.js +++ b/hacking/NavAngular.js @@ -16,6 +16,7 @@ angular.module('ionic.ui', ['ngTouch']) .controller('NavCtrl', function($scope) { var _this = this; + angular.extend(this, NavController.prototype); NavController.call(this, { @@ -25,11 +26,20 @@ angular.module('ionic.ui', ['ngTouch']) shouldGoBack: function() { }, setTitle: function(title) { + $scope.title = title; }, showBackButton: function(show) { }, } }); + + $scope.controllers = this.controllers; + + $scope.getTopController = function() { + return $scope.controllers[$scope.controllers.length-1]; + } + + $scope.push = this.push; }) .directive('navController', function() { @@ -41,7 +51,7 @@ angular.module('ionic.ui', ['ngTouch']) controller: 'NavCtrl', //templateUrl: 'ext/angular/tmpl/ionicTabBar.tmpl.html', template: '
', - compile: function(element, attr, transclude, tabsCtrl) { + compile: function(element, attr, transclude, navCtrl) { return function($scope, $element, $attr) { }; } @@ -54,6 +64,8 @@ angular.module('ionic.ui', ['ngTouch']) require: '^navController', transclude: true, replace: true, + scope: { + }, template: '' @@ -62,18 +74,13 @@ angular.module('ionic.ui', ['ngTouch']) .directive('navContent', function() { return { - restrict: 'E', + restrict: 'C', require: '^navController', - scope: { - title: '=' - }, transclude: true, replace: true, template: '
', - link: function(scope, element, attrs, tabsCtrl) { - scope.$watch('title', function(value) { - console.log('Title chnaged', value); - }); + link: function(scope, element, attrs, navCtrl) { + navCtrl.push(scope); } } }); diff --git a/hacking/NavController.js b/hacking/NavController.js index 579c6572c0..864e8d079b 100644 --- a/hacking/NavController.js +++ b/hacking/NavController.js @@ -2,10 +2,13 @@ NavController = function(opts) { var _this = this; + console.log('CONSTRUCTOR', this); + this.navBar = opts.navBar; this.content = opts.content; this.controllers = opts.controllers || []; + this._updateNavBar(); // TODO: Is this the best way? this.navBar.shouldGoBack = function() { @@ -18,10 +21,12 @@ return this.controllers; }, getTopController: function() { - return this.topController; + return this.controllers[this.controllers.length-1]; }, push: function(controller) { - var last = this.topController; + console.log('PUSHING'); + + var last = this.controllers[this.controllers.length - 1]; this.controllers.push(controller); @@ -36,15 +41,17 @@ // Remove the old one //last && last.detach(); + if(last) { + last.isVisible = false; + last.visibilityChanged && last.visibilityChanged(); + } // Grab the top controller on the stack var next = this.controllers[this.controllers.length - 1]; // TODO: No DOM stuff here //this.content.el.appendChild(next.el); - - // Switch to it (TODO: Animate or such things here) - this.topController = next; + console.log('Top controller modified', this.topController); this._updateNavBar(); @@ -72,6 +79,7 @@ // Switch to it (TODO: Animate or such things here) this.topController = next; + console.log('Top controller modified', this.topController); this._updateNavBar(); @@ -79,6 +87,10 @@ }, _updateNavBar: function() { + if(!this.topController) { + return; + } + this.navBar.setTitle(this.topController.title); if(this.controllers.length > 1) { diff --git a/hacking/TabAngular.js b/hacking/TabAngular.js index bb269c2b68..3b4ce48629 100644 --- a/hacking/TabAngular.js +++ b/hacking/TabAngular.js @@ -31,6 +31,11 @@ angular.module('ionic.ui', ['ngTouch']) }); $scope.controllers = this.controllers; + + $scope.$watch('controllers', function(newV, oldV) { + console.log("CControlelrs changed", newV, oldV); + $scope.$apply(); + }); }) .directive('tabs', function() { diff --git a/hacking/navAngular.html b/hacking/navAngular.html index de75b9f846..e0d4add29a 100644 --- a/hacking/navAngular.html +++ b/hacking/navAngular.html @@ -14,13 +14,14 @@ - - -

{{title}}

-
+ +
@@ -28,7 +29,13 @@