mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 23:16:52 +08:00
Fixed #79
This commit is contained in:
59
dist/js/ionic-angular.js
vendored
59
dist/js/ionic-angular.js
vendored
@ -154,7 +154,35 @@ angular.module('ionic.service.loading', ['ionic.ui.loading'])
|
||||
angular.module('ionic.service.modal', ['ionic.service.templateLoad'])
|
||||
|
||||
|
||||
.factory('Modal', ['$rootScope', '$document', '$compile', 'TemplateLoader', function($rootScope, $document, $compile, TemplateLoader) {
|
||||
.factory('Modal', ['$rootScope', '$document', '$compile', '$animate', 'TemplateLoader', function($rootScope, $document, $compile, $animate, TemplateLoader) {
|
||||
var ModalView = ionic.views.Modal.inherit({
|
||||
initialize: function(opts) {
|
||||
ionic.views.Modal.prototype.initialize.call(this, opts);
|
||||
this.animation = opts.animation;
|
||||
},
|
||||
// Show the modal
|
||||
show: function() {
|
||||
var element = angular.element(this.el);
|
||||
if(!element.parent().length) {
|
||||
$animate.enter(element, angular.element($document[0].body));
|
||||
}
|
||||
$animate.addClass(element, this.animation);
|
||||
},
|
||||
// Hide the modal
|
||||
hide: function() {
|
||||
var element = angular.element(this.el);
|
||||
$animate.removeClass(element, this.animation);
|
||||
},
|
||||
|
||||
// Remove and destroy the modal scope
|
||||
remove: function() {
|
||||
var element = angular.element(this.el);
|
||||
$animate.leave(angular.element(this.el), function() {
|
||||
scope.$destroy();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
/**
|
||||
* Load a modal with the given template string.
|
||||
@ -162,33 +190,34 @@ 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, $scope) {
|
||||
// Create a new isolated scope for the modal
|
||||
var scope = $scope && $scope.$new() || $rootScope.$new(true);
|
||||
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);
|
||||
$document[0].body.appendChild(element[0]);
|
||||
|
||||
var modal = new ionic.views.Modal({el: element[0] });
|
||||
scope.modal = modal;
|
||||
options.el = element[0];
|
||||
var modal = new ModalView(options);
|
||||
return modal;
|
||||
},
|
||||
fromTemplateUrl: function(url, cb, $scope) {
|
||||
fromTemplateUrl: function(url, cb, options) {
|
||||
TemplateLoader.load(url).then(function(templateString) {
|
||||
// Create a new isolated scope for the modal
|
||||
var scope = $scope && $scope.$new() || $rootScope.$new(true);
|
||||
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);
|
||||
$document[0].body.appendChild(element[0]);
|
||||
|
||||
var modal = new ionic.views.Modal({ el: element[0] });
|
||||
scope.modal = modal;
|
||||
|
||||
options.el = element[0];
|
||||
var modal = new ModalView(options);
|
||||
|
||||
cb(modal);
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
}]);
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user