私のコントローラには、2つのモーダルが起動しています。そのうちの1つのコードは、モーダルコードをIonicでどこに移動する必要がありますか?
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
});
}
であり、他のモーダルコードはさらに長くなります。 私のコントローラクラスがそれほど大きくないように、このコードをリファクタリングする最良の方法は何ですか?
このコードをサービスに移行する必要がありますか?
おかげアーディティヤ、私はそれをやってみますよ。本当に助けに感謝します。 –
私はあなたが探していた正確な実装を持っているionic forumへのリンクを追加しました –