Why is $uibModalInstance unable to be injected here?
http://plnkr.co/edit/mi9Ytv0HaqE47ENod4Gn?p=preview
baseController.$inject = ['$uibModal', '$uibModalInstance'];
function baseController($uibModal, $uibModalInstance) {
self.ok = function () {
$uibModalInstance.close(self.selected.item);
};
self.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
I am trying to access $uibModalInstance and if I try to inject it, I get an injection error.
If I don't inject it, then it's Undefined...
So LOTS of great statements here, but none of them quite solved the issue.
amg-argh got my plkr working with the way I had set up my injection
http://plnkr.co/edit/GXXmUosUEnEO3Tk0gUyp?p=preview
The biggest magic came from this edit here...
var childController = function ($scope, $uibModalInstance) {
$scope.ok = function () {
$uibModalInstance.close({ my: 'data' });
}
$scope.cancel = function () {
$uibModalInstance.dismiss();
}
}
self.open = function (size) {
var modalInstance = $uibModal.open({
animation: self.animationsEnabled,
templateUrl: 'help.html',
controller: childController,
size: size
});
};
+++++++++++++++++++++++++++++
I also want to make a note that this SHOULD be done later on as a Service, just as icfantv has pointed out. But I need to figure out the syntax for returning and consuming the modal's promise...
Thank you everyone for your help!!
Cheers!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With