Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 7a7ad06

Browse files
committed
fix(modal): fix bindToController implementation
- Correct the implementation of `bindToController` to match Angular with properties on `$scope` being bound on the controller
1 parent f45b4a4 commit 7a7ad06

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: src/modal/modal.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -538,10 +538,10 @@ angular.module('ui.bootstrap.modal', [])
538538
ctrlInstance = $controller(modalOptions.controller, ctrlLocals);
539539
if (modalOptions.controllerAs) {
540540
if (modalOptions.bindToController) {
541-
angular.extend(modalScope, ctrlInstance);
542-
} else {
543-
modalScope[modalOptions.controllerAs] = ctrlInstance;
541+
angular.extend(ctrlInstance, modalScope);
544542
}
543+
544+
modalScope[modalOptions.controllerAs] = ctrlInstance;
545545
}
546546
}
547547

Diff for: src/modal/test/modal.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ describe('$modal', function () {
480480
});
481481

482482
it('should allow usage of bindToController', function () {
483-
open({template: '<div>{{fromCtrl}} {{isModalInstance}}</div>', controller: function($modalInstance) {
483+
open({template: '<div>{{test.fromCtrl}} {{test.isModalInstance}}</div>', controller: function($modalInstance) {
484484
this.fromCtrl = 'Content from ctrl';
485485
this.isModalInstance = angular.isObject($modalInstance) && angular.isFunction($modalInstance.close);
486486
}, controllerAs: 'test', bindToController: true});

0 commit comments

Comments
 (0)