Working modal stuff

This commit is contained in:
Max Lynch
2013-10-04 17:47:54 -05:00
parent e8d76af832
commit c338f75882
12 changed files with 214 additions and 95 deletions

View File

@ -0,0 +1,37 @@
angular.module('ionic.service.modal', ['ionic.service'])
.factory('Modal', ['$rootScope', '$document', '$compile', 'TemplateLoader', function($rootScope, $document, $compile, TemplateLoader) {
return {
/**
* Load a modal with the given template string.
*
* A new isolated scope will be created for the
* modal and the new element will be appended into the body.
*/
fromTemplate: function(templateString) {
// Create a new isolated scope for the modal
var scope = $rootScope.$new(true);
// Compile the template
var element = $compile(templateString)(scope);
$document[0].body.appendChild(element[0]);
return new ionic.views.Modal({el: element[0] });
},
fromTemplateUrl: function(url, cb) {
TemplateLoader.load(url).then(function(templateString) {
// Create a new isolated scope for the modal
var scope = $rootScope.$new(true);
// Compile the template
var element = $compile(templateString)(scope);
$document[0].body.appendChild(element[0]);
var modal = new ionic.views.Modal({ el: element[0] });
cb(modal);
});
}
};
}]);