From 7f4147ea06af320b7eace517eccd9b587f79646a Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Mon, 4 Nov 2013 18:43:08 -0600 Subject: [PATCH] Added alternative $scope inherit for Modal --- dist/js/ionic-angular.js | 21 +++++++++++++++------ js/ext/angular/src/ionicAngular.js | 13 +++++++++++-- js/ext/angular/src/service/ionicModal.js | 8 ++++---- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/dist/js/ionic-angular.js b/dist/js/ionic-angular.js index b265a7a279..cb57ce5804 100644 --- a/dist/js/ionic-angular.js +++ b/dist/js/ionic-angular.js @@ -2,6 +2,14 @@ * Create a wrapping module to ease having to include too many * modules. */ +angular.module('ionic.service', [ + 'ionic.service.actionSheet', + 'ionic.service.gesture', + 'ionic.service.loading', + 'ionic.service.modal', + 'ionic.service.popup', + 'ionic.service.templateLoad' +]); angular.module('ionic.ui', [ 'ionic.ui.content', @@ -15,8 +23,9 @@ angular.module('ionic.ui', [ angular.module('ionic', [ 'ionic.platform', - 'ionic.ui' -]) + 'ionic.service', + 'ionic.ui', +]); ; angular.module('ionic.service.actionSheet', ['ionic.service.templateLoad', 'ionic.ui.actionSheet']) @@ -153,9 +162,9 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad']) * A new isolated scope will be created for the * modal and the new element will be appended into the body. */ - fromTemplate: function(templateString) { + fromTemplate: function(templateString, $scope) { // Create a new isolated scope for the modal - var scope = $rootScope.$new(true); + var scope = $scope && $scope.$new() || $rootScope.$new(true); // Compile the template var element = $compile(templateString)(scope); @@ -165,10 +174,10 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad']) scope.modal = modal; return modal; }, - fromTemplateUrl: function(url, cb) { + fromTemplateUrl: function(url, cb, $scope) { TemplateLoader.load(url).then(function(templateString) { // Create a new isolated scope for the modal - var scope = $rootScope.$new(true); + var scope = $scope && $scope.$new() || $rootScope.$new(true); // Compile the template var element = $compile(templateString)(scope); diff --git a/js/ext/angular/src/ionicAngular.js b/js/ext/angular/src/ionicAngular.js index 23c10eabfb..4ab2e1a4be 100644 --- a/js/ext/angular/src/ionicAngular.js +++ b/js/ext/angular/src/ionicAngular.js @@ -2,6 +2,14 @@ * Create a wrapping module to ease having to include too many * modules. */ +angular.module('ionic.service', [ + 'ionic.service.actionSheet', + 'ionic.service.gesture', + 'ionic.service.loading', + 'ionic.service.modal', + 'ionic.service.popup', + 'ionic.service.templateLoad' +]); angular.module('ionic.ui', [ 'ionic.ui.content', @@ -15,5 +23,6 @@ angular.module('ionic.ui', [ angular.module('ionic', [ 'ionic.platform', - 'ionic.ui' -]) + 'ionic.service', + 'ionic.ui', +]); diff --git a/js/ext/angular/src/service/ionicModal.js b/js/ext/angular/src/service/ionicModal.js index 5bf276cae1..90318c8cf6 100644 --- a/js/ext/angular/src/service/ionicModal.js +++ b/js/ext/angular/src/service/ionicModal.js @@ -9,9 +9,9 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad']) * A new isolated scope will be created for the * modal and the new element will be appended into the body. */ - fromTemplate: function(templateString) { + fromTemplate: function(templateString, $scope) { // Create a new isolated scope for the modal - var scope = $rootScope.$new(true); + var scope = $scope && $scope.$new() || $rootScope.$new(true); // Compile the template var element = $compile(templateString)(scope); @@ -21,10 +21,10 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad']) scope.modal = modal; return modal; }, - fromTemplateUrl: function(url, cb) { + fromTemplateUrl: function(url, cb, $scope) { TemplateLoader.load(url).then(function(templateString) { // Create a new isolated scope for the modal - var scope = $rootScope.$new(true); + var scope = $scope && $scope.$new() || $rootScope.$new(true); // Compile the template var element = $compile(templateString)(scope);