Upon further investigation, it appears that the issue is quite amusing.
It seems that when angular-strap is fetched via bower or npm, there is a discrepancy with the $modal
. In the locally stored version of angular-strap, even in the latest release 2.3.8, references to onShow
or onHide
are not present.
Inspecting the source code on the github repository reveals the truth -> https://github.com/mgcrea/angular-strap/blob/master/src/modal/modal.js
Interestingly, onShow
and onHide
are indeed being triggered in the github repo. This suggests that the modal component is not synchronized with the rest of angular-strap in the distributed versions.
The documentation is not at fault (which was my initial assumption), rather it is the downloaded source that is outdated!
To enable support for onShow
, etc., one must merge the latest /modal
from the github repo into the local angular-strap. Personally, I opt not to do this as it may lead to complications during upgrades. However, now I understand the reason behind sticking with the original answer.
In my experience, utilizing options like onShow
etc. proves to be redundant. Instead, I rely on handlers for the modal.show
/ modal.hide
events, which are always broadcasted. In instances of multiple modals (modals overlaid on each other), assigning tags to the modals can prevent confusion.
var _modal = $modal({
templateUrl: "app/pages/fee/modals/historic/fee.historic.html",
controller: "HistoricController",
controllerAs: "vm",
keyboard: true,
show: false,
tag: 'myModal'
}
$scope.$on('modal.show', function(e, target) {
if (target.$options.tag == 'myModal') {
//do stuff here
}
})
$scope.$on('modal.hide', function(e, target) {
if (target.$options.tag == 'myModal') {
//do stuff here
}
})