New to ui-bootstrap and I've gotten the modal to appear, but can't get it to dismiss with a button press. I've tried a many combinations but nothing seems to work (or it makes the modal not appear at all).
The modal is in a separate file as:
<div ng-controller = 'entryCtrl' class="modal" id="modal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header"></div>
<div class="modal-body">
<div class="modal-inner-content">
</div>
<div class="modal-footer" id="modal-footer">
<button type="button" class="btn btn-success" ng-click="cancel()"><i class="glyphicon glyphicon-backward"></i> Back</button>
<button type="button" class="btn btn-danger" ng-click="ok()"><i class="glyphicon glyphicon-forward"></i> Continue</button>
</div>
</div>
</div>
</div>
</div>
It's called in a different html file with the same controller (I tried having them as different controllers, but then variables wouldn't appear to inject at all, i.e. the modal instance would be undefined).
In the controller, I can get the thing to open as:
xControllers.controller('entryCtrl', [
'$scope', '$window', '$modal', '$log',
'SharedProperties',
function ($scope, $window, $modal, $log,
SharedProperties) {
$scope.open = function (size) {
$scope.modal = $modal({
templateUrl: './views/modals/possible_slurs.html',
controllerAs: ['$window', '$log', '$modalInstance', function ($window, $log, $modalInstance) {
this.ok = function () {
$modalInstance.close();
};
this.cancel = function () {
$modalInstance.dismiss('cancel');
$window.history.back();
};
}],
scope: $scope
});
};
}]);
For some reason the $modal.open()
doesn't work, and template
, and controller
parameters don't either (it only accepts templateUrl
and controllerAs
).
I attempted to have controllerAs
set as a different controller, but then that separate controller wouldn't recognize the modal instance (it came up as undefined).
I have my dependencies set as:
var x = angular.module('x-app', [
'xControllers',
'ngAnimate',
'ngRoute',
'ngResource',
'mgcrea.ngStrap',
'angularUtils.directives.dirPagination',
'ui.bootstrap'
]);
And their versions:
"dependencies": {
"socket.io": "^2.2.0",
"angular": "^1.7.8",
"angular-animate": "^1.7.8",
"angular-motion": "^0.4.4",
"angular-resource": "^1.7.8",
"angular-strap": "^2.3.12",
"bootstrap": "^4.3.1",
"jquery": "^3.4.1",
"angular-bootstrap": "^2.5.0"
}
Thank you so much and please let me know if more information is needed to help with this!