diff --git a/src/modal/docs/readme.md b/src/modal/docs/readme.md index 1100c95611..1a0be3f066 100644 --- a/src/modal/docs/readme.md +++ b/src/modal/docs/readme.md @@ -8,7 +8,7 @@ The `$modal` service has only one method: `open(options)` where available option * `scope` - a scope instance to be used for the modal's content (actually the `$modal` service is going to create a child scope of a provided scope). Defaults to `$rootScope` * `controller` - a controller for a modal instance - it can initialize scope used by modal. Accepts the "controller-as" syntax in the form 'SomeCtrl as myctrl'; can be injected with `$modalInstance` * `controllerAs` - an alternative to the controller-as syntax, matching the API of directive definitions. Requires the `controller` option to be provided as well -* `bindToController` - when used with `controllerAs` & set to `true`, it will bind the controller properties onto the `$scope` directly +* `bindToController` - when used with `controllerAs` & set to `true`, it will bind the $scope properties onto the controller directly * `resolve` - members that will be resolved and passed to the controller as locals; it is equivalent of the `resolve` property for AngularJS routes * `animation` - set to false to disable animations on new modal/backdrop. Does not toggle animations for modals/backdrops that are already displayed. * `backdrop` - controls presence of a backdrop. Allowed values: true (default), false (no backdrop), `'static'` - backdrop is present but modal window is not closed when clicking outside of the modal window. diff --git a/src/modal/modal.js b/src/modal/modal.js index 0c0405f0d7..eadc44e777 100644 --- a/src/modal/modal.js +++ b/src/modal/modal.js @@ -538,10 +538,10 @@ angular.module('ui.bootstrap.modal', []) ctrlInstance = $controller(modalOptions.controller, ctrlLocals); if (modalOptions.controllerAs) { if (modalOptions.bindToController) { - angular.extend(modalScope, ctrlInstance); - } else { - modalScope[modalOptions.controllerAs] = ctrlInstance; + angular.extend(ctrlInstance, modalScope); } + + modalScope[modalOptions.controllerAs] = ctrlInstance; } } diff --git a/src/modal/test/modal.spec.js b/src/modal/test/modal.spec.js index 15459a820d..f70ae6ee00 100644 --- a/src/modal/test/modal.spec.js +++ b/src/modal/test/modal.spec.js @@ -480,7 +480,7 @@ describe('$modal', function () { }); it('should allow usage of bindToController', function () { - open({template: '