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

Commit

Permalink
chore(modal): use $controller to apply controllerAs
Browse files Browse the repository at this point in the history
- Change to use `$controller` to apply the `controllerAs` feature

Closes #5861
  • Loading branch information
ruiann authored and wesleycho committed Apr 29, 2016
1 parent 1611248 commit 5741be9
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -702,23 +702,16 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap', 'ui.bootstrap.p

// the third param will make the controller instantiate later,private api
// @see https://github.com/angular/angular.js/blob/master/src/ng/controller.js#L126
ctrlInstantiate = $controller(modalOptions.controller, ctrlLocals, true);
if (modalOptions.controllerAs) {
ctrlInstantiate = $controller(modalOptions.controller, ctrlLocals, true, modalOptions.controllerAs);
if (modalOptions.controllerAs && modalOptions.bindToController) {
ctrlInstance = ctrlInstantiate.instance;

if (modalOptions.bindToController) {
ctrlInstance.$close = modalScope.$close;
ctrlInstance.$dismiss = modalScope.$dismiss;
angular.extend(ctrlInstance, providedScope);
}

ctrlInstance = ctrlInstantiate();

modalScope[modalOptions.controllerAs] = ctrlInstance;
} else {
ctrlInstance = ctrlInstantiate();
ctrlInstance.$close = modalScope.$close;
ctrlInstance.$dismiss = modalScope.$dismiss;
angular.extend(ctrlInstance, providedScope);
}

ctrlInstance = ctrlInstantiate();

if (angular.isFunction(ctrlInstance.$onInit)) {
ctrlInstance.$onInit();
}
Expand Down

0 comments on commit 5741be9

Please sign in to comment.