In my controller, I have two modals that are launched. The code for one of them is:
function setUpEditCommentModal() {
$ionicModal.fromTemplateUrl('app/recent/edit-comment-modal.html', {
scope: $scope, // so close methods available.
animation: 'fade-in-scale'
}).then(function (modal) {
$scope.editCommentModal = modal;
});
$scope.closeEditCommentModal = function () {
$scope.editCommentModal.hide();
};
$scope.returnFromSavingCommentInModal = function () {
var modifiedComment = commentSelector.getComment();
vm.selectedComment.Comment = modifiedComment.Comment; // just note part.
$scope.closeEditCommentModal();
};
//Cleanup the modal when we're done with it!
$scope.$on('$destroy', function () {
$scope.editCommentModal.remove();
});
// Execute action on hide modal
$scope.$on('modal.hidden', function () {
// Execute action
$ionicListDelegate.closeOptionButtons();
});
// Execute action on remove modal
$scope.$on('modal.removed', function () {
// Execute action
});
}
and the other modal code is even longer. What is the best way to refactor this code so that my controller class is not too big?
Should I move this code into a service?