Skip to content

Instantly share code, notes, and snippets.

@eloytoro
Created September 30, 2015 21:36
Show Gist options
  • Save eloytoro/890651af2915583e8834 to your computer and use it in GitHub Desktop.
Save eloytoro/890651af2915583e8834 to your computer and use it in GitHub Desktop.
.service('Modal', function (ModalTemplate, $timeout, $q) {
this.confirm = new ModalTemplate({
templateUrl: 'views/modals/confirm.html',
});
var self = this;
this.newPoll = new ModalTemplate({
templateUrl: 'views/modals/new-poll.html',
containerUrl: 'views/directives/modal-template.html',
resolve: {
templates: /*@ngInject*/ function (PollResource) {
return PollResource.templates().$promise
}
},
defaults: {
dismiss: function () {
var modal = self.confirm.render({
message: 'Estas seguro de que no vas a crear un sondeo'
});
return modal.when('accept');
}
},
controller: /*@ngInject*/ function ($scope, $modal, PollResource, $state, templates) {
$scope.templates = templates;
$scope.selectTemplate = function () {
if (!this.template) return;
$scope.disabled = true;
var clone = PollResource.clone({}, {
_id: this.template
}, function () {
$state.go('user.polls.edit', { poll: clone._id }, {
inherit: false,
reload: true
});
$modal.dismiss();
});
};
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment