Created
September 30, 2015 21:36
-
-
Save eloytoro/890651af2915583e8834 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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