In my code using UI-Router and Bootstrap-ui modal, I have defined the state as shown below. reference
var state = {
name: 'modala',
parent: 'home',
onEnter: function($modal, $state) {
modalInstance = $modal.open({
templateUrl: 'modala.html',
controller: 'modalaCtrl',
controllerAs: 'modal'
});
modalInstance.result['finaly'](function() {
modalInstance = null;
if ($state.$current.name === 'modala') {
$state.go('^');
}
});
},
onExit: function() {
if (modalInstance) {
modalInstance.close();
}
}
};
I am looking for a way to use 'modala' outside of the 'home' state.
I don't want to repeatedly define 'modala'
.
Is there a method to make this work without specifying the parent every time?
Suggested Solutions:
1. Do not specify the parent in the modal state.
Result: The modal window will not be displayed within its designated parent.
2. Name the modal state as ${parent.name}.modal format.
Result: This approach works, but it requires defining multiple states for each modal window and adding a state for every new parent that calls the modal.
3. Define the modal state separately for each parent.
Result: Similar to pattern 2.