diff --git a/src/modal/docs/readme.md b/src/modal/docs/readme.md index 11badf65a8..ccc539f48d 100644 --- a/src/modal/docs/readme.md +++ b/src/modal/docs/readme.md @@ -16,4 +16,9 @@ The `open` method returns a modal instance, an object with the following propert * `close(result)` - a method that can be used to close a modal, passing a result * `dismiss(reason)` - a method that can be used to dismiss a modal, passing a reason * `result` - a promise that is resolved when a modal is closed and rejected when a modal is dismissed -* `opened` - a promise that is resolved when a modal gets opened after downloading content's template and resolving all variables \ No newline at end of file +* `opened` - a promise that is resolved when a modal gets opened after downloading content's template and resolving all variables + +In addition the scope associated with modal's content is augmented with 2 methods: +* `$close(result)` +* `$dismiss(reason)` +Those methods make it easy to close a modal window without a need to create a dedicated controller \ No newline at end of file diff --git a/src/modal/modal.js b/src/modal/modal.js index 2b7752bb03..58a6870e9f 100644 --- a/src/modal/modal.js +++ b/src/modal/modal.js @@ -247,10 +247,10 @@ angular.module('ui.bootstrap.modal', []) result: modalResultDeferred.promise, opened: modalOpenedDeferred.promise, close: function (result) { - $modalStack.close(this, result); + $modalStack.close(modalInstance, result); }, dismiss: function (reason) { - $modalStack.dismiss(this, reason); + $modalStack.dismiss(modalInstance, reason); } }; @@ -270,6 +270,8 @@ angular.module('ui.bootstrap.modal', []) templateAndResolvePromise.then(function resolveSuccess(tplAndVars) { var modalScope = (modalOptions.scope || $rootScope).$new(); + modalScope.$close = modalInstance.close; + modalScope.$dismiss = modalInstance.dismiss; var ctrlInstance, ctrlLocals = {}; var resolveIter = 1;