I have a modal window that I use to present a form to users. They enter the information and then press a button the has an ng-click. The server processes the request and s
I have remixed the answer by @isubuz and this answer by @Umur Kontacı on attribute directives into a version where your controller doesn't call a DOM-like operation like "dismiss", but instead tries to be more MVVM style, setting a boolean property isInEditMode. The view in turn links this bit of info to the attribute directive that opens/closes the bootstrap modal.
var app = angular.module('myApp', []);
app.directive('myModal', function() {
return {
restrict: 'A',
scope: { myModalIsOpen: '=' },
link: function(scope, element, attr) {
scope.$watch(
function() { return scope.myModalIsOpen; },
function() { element.modal(scope.myModalIsOpen ? 'show' : 'hide'); }
);
}
}
});
app.controller('MyCtrl', function($scope) {
$scope.isInEditMode = false;
$scope.toggleEditMode = function() {
$scope.isInEditMode = !$scope.isInEditMode;
};
});
isInEditMode == {{isInEditMode}}