mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 06:57:02 +08:00
Lots of little tweaks
This commit is contained in:
43
dist/js/ionic-angular.js
vendored
43
dist/js/ionic-angular.js
vendored
@ -158,7 +158,7 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad'])
|
||||
var ModalView = ionic.views.Modal.inherit({
|
||||
initialize: function(opts) {
|
||||
ionic.views.Modal.prototype.initialize.call(this, opts);
|
||||
this.animation = opts.animation;
|
||||
this.animation = opts.animation || 'slide-in-up';
|
||||
},
|
||||
// Show the modal
|
||||
show: function() {
|
||||
@ -183,6 +183,25 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad'])
|
||||
}
|
||||
});
|
||||
|
||||
var createModal = function(templateString, options) {
|
||||
// Create a new scope for the modal
|
||||
var scope = options.scope && options.scope.$new() || $rootScope.$new(true);
|
||||
|
||||
// Compile the template
|
||||
var element = $compile(templateString)(scope);
|
||||
|
||||
options.el = element[0];
|
||||
var modal = new ModalView(options);
|
||||
|
||||
// If this wasn't a defined scope, we can assign 'modal' to the isolated scope
|
||||
// we created
|
||||
if(!options.scope) {
|
||||
scope.modal = modal;
|
||||
}
|
||||
|
||||
return modal;
|
||||
};
|
||||
|
||||
return {
|
||||
/**
|
||||
* Load a modal with the given template string.
|
||||
@ -191,30 +210,12 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad'])
|
||||
* modal and the new element will be appended into the body.
|
||||
*/
|
||||
fromTemplate: function(templateString, options) {
|
||||
options = options || {};
|
||||
// Create a new scope for the modal
|
||||
var scope = options.scope && options.scope.$new() || $rootScope.$new(true);
|
||||
|
||||
// Compile the template
|
||||
var element = $compile(templateString)(scope);
|
||||
|
||||
options.el = element[0];
|
||||
var modal = new ModalView(options);
|
||||
var modal = createModal(templateString, options || {});
|
||||
return modal;
|
||||
},
|
||||
fromTemplateUrl: function(url, cb, options) {
|
||||
TemplateLoader.load(url).then(function(templateString) {
|
||||
options = options || {};
|
||||
|
||||
// Create a new scope for the modal
|
||||
var scope = options.scope && options.scope.$new() || $rootScope.$new(true);
|
||||
|
||||
// Compile the template
|
||||
var element = $compile(templateString)(scope);
|
||||
|
||||
options.el = element[0];
|
||||
var modal = new ModalView(options);
|
||||
|
||||
var modal = createModal(templateString, options || {});
|
||||
cb(modal);
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user