Hacking Angular Stuff

This commit is contained in:
Max Lynch
2013-10-03 20:18:23 -05:00
parent 52bf562b05
commit 153a8de7a1
8 changed files with 135 additions and 42 deletions

64
dist/ionic-angular.js vendored
View File

@ -1,5 +1,21 @@
angular.module('ionic.ui', ['ionic.ui.content', 'ionic.ui.tabs', 'ionic.ui.nav', 'ionic.ui.sideMenu']);
;
angular.module('ionic.service', [])
.factory('TemplateLoader', ['$q', '$http', '$templateCache', function($q, $http, $templateCache) {
return {
load: function(url) {
var deferred = $q.defer();
$http.get(url, { cache: $templateCache }).success(function(html) {
deferred.resolve(html && html.trim());
});
return deferred.promise;
}
}
}]);
;
angular.module('ionic.ui.content', {})
// The content directive is a core scrollable content area
@ -24,13 +40,26 @@ angular.module('ionic.ui.content', {})
}
})
;
angular.module('ionic.ui.nav', [])
angular.module('ionic.ui.nav', ['ionic.service'])
.controller('NavCtrl', function($scope, $element, $compile) {
.controller('NavCtrl', ['$scope', '$element', '$compile', 'TemplateLoader', function($scope, $element, $compile, TemplateLoader) {
var _this = this;
angular.extend(this, ionic.controllers.NavController.prototype);
this.pushFromTemplate = function(tmpl) {
data = TemplateLoader.load(tmpl).then(function(data) {
console.log('Nav loaded template', data);
var childScope = $scope.$new();
childScope.isVisible = true;
$compile(data)(childScope, function(cloned, scope) {
$element.append(cloned);
});
});
}
ionic.controllers.NavController.call(this, {
content: {
},
@ -38,34 +67,28 @@ angular.module('ionic.ui.nav', [])
shouldGoBack: function() {
},
setTitle: function(title) {
$scope.title = title;
$scope.navController.title = title;
},
showBackButton: function(show) {
},
}
});
$scope.controllers = this.controllers;
$scope.getTopController = function() {
return $scope.controllers[$scope.controllers.length-1];
}
$scope.pushController = function(controller) {
_this.push(controller);
}
$scope.pushController = function(scope) {
_this.push(scope);
};
$scope.navController = this;
})
}])
.directive('navController', function() {
.directive('navCtrl', function() {
return {
restrict: 'E',
replace: true,
transclude: true,
controller: 'NavCtrl',
//templateUrl: 'ext/angular/tmpl/ionicTabBar.tmpl.html',
template: '<div class="view"><div ng-transclude></div></div>',
template: '<div class="view" ng-transclude></div>',
compile: function(element, attr, transclude, navCtrl) {
return function($scope, $element, $attr) {
};
@ -100,6 +123,15 @@ angular.module('ionic.ui.nav', [])
scope.title = attrs.title;
scope.isVisible = true;
scope.pushController(scope);
scope.$watch('isVisible', function(value) {
console.log('Visiblity changed', value);
if(value) {
element[0].classList.remove('hidden');
} else {
element[0].classList.add('hidden');
}
});
}
}
});
@ -164,7 +196,7 @@ angular.module('ionic.ui.sideMenu', [])
$scope.contentTranslateX = 0;
})
.directive('sideMenuController', function() {
.directive('sideMenuCtrl', function() {
return {
restrict: 'E',
controller: 'SideMenuCtrl',