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

$modal.open() does not support controllerAs option #2242

Closed
zandroid opened this issue May 22, 2014 · 6 comments
Closed

$modal.open() does not support controllerAs option #2242

zandroid opened this issue May 22, 2014 · 6 comments

Comments

@zandroid
Copy link

Angular supports the option "controllerAs" for directives. I would like to see it for $modal.open() also. Please, look at a sample plunker.

@pkozlowski-opensource
Copy link
Member

@zandroid it is supported already but using the syntax used by the the ngController directive:

this.modal2 = function() {
    $modal.open({
      controller: 'modalController2 as modal',
      templateUrl: 'modal2.html'
    });
  };

Check this http://plnkr.co/edit/O9ALTGT83OZZCIryaLw2?p=preview

@zandroid
Copy link
Author

@pkozlowski-opensource, Thanks.
I no need the following case, FYI only, but it does not work if a controller was defined as inline function, look at http://plnkr.co/edit/q6RwZP?p=preview

$modal.open({
    controller: function() { ... },
    controllerAs: 'modal',
    templateUrl: 'modal.html'
});

@pkozlowski-opensource
Copy link
Member

@zandroid I see. Since it is very easy to support both forms of syntax I've just pushed a commit 8d7c2a2 where it is possible to do what you were asking for. I hope It won't cause too much confusion for our users to have 2 different ways of doing the same thing....

@zandroid
Copy link
Author

It works when a controller is defined by string. But I'm not sure that it works for inline function (I'm think it does not). Please look at my message above, I was defined controller as inline function, not a string. You can use the plunker sample for test writing.

@pkozlowski-opensource
Copy link
Member

@zandroid you are right. Pushed 7910536 to fix this, thnx for providing detailed info!

@zandroid
Copy link
Author

Thank you for fix.

dearlordylord pushed a commit to dearlordylord/bootstrap that referenced this issue Jun 18, 2014
dearlordylord pushed a commit to dearlordylord/bootstrap that referenced this issue Jun 18, 2014
OronNadiv pushed a commit to lanetix/bootstrap that referenced this issue Nov 18, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants