# The right place to place angular modal

In my app I have a BaseCtrl, which is attached to the body element and is available everywhere. In the mentioned controller I have the following code for opening modal:

    $scope.addFolder = function($event) {
$event.preventDefault(); // Opens an add folder modal var modal = ModalService.custom({ templateUrl: '/partials/modals/create-folder.html', controller: ['$scope',
function($innerScope) {$innerScope.modal = modal;

$innerScope.create = function() { var result = NodesService.createFolder($innerScope.new_folder, $scope.location); result.then(function(resp) { modal.close(); ModalService.flash('CREATED_SUCCESSFULLY');$rootScope.$emit('update_nodes'); }, function(err) {$innerScope.create_folder_error = Locales.get(err.data.message);
});
};

}
]
});
};


I thought it's the most appropriate place to put this snippet, since I need to be able to access it app-wide. My question is should I separate this method in different controller or should I place it in a factory/service? What is the right place to put such code in angular?