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

fix(modal): fix bindToController implementation #4054

Closed

Conversation

wesleycho
Copy link
Contributor

  • Correct the implementation of bindToController to match Angular with properties on $scope being bound on the controller

Fixes #4051

@drpicox
Copy link

drpicox commented Jul 31, 2015

Nice!

(as following which I started in #3965 )

It happened to me looking for ways to make "mastermodals" that I can accomodate for many uses. Ex:

In angular 1.4, although it is not well documented, you can use bindToController as follows:

scope: {}, // <-- personal recommendation to avoid problems
bindToController: {
   name: '=',
},

What it is doing is assigning binding values to controller. It may be useful for assigning values to modal controllers (without creating custom $scopes):

bindToController: {
   name: function(nameService) { return nameService.get(); },
}

or may be:

resolve: {
   name: function(nameService) { return nameService.get(); },
},
bindToController: {
   name: '=',
},

But I still do not like any of both (probably just not the right naming).

The idea is to allow do something like the following example but without doing a sort of hacking (something too complex to write and understand because the lacking of desidered/useful feature):

scope: customScope,
resolve: {
   __unused_by_controller__name: function(nameService) {
     return nameService.get().then(function(name) {
        customScope.name = name;
     };
  }
},

It is required because if you do an modal.open you are expected to return a modal, not a promise to a modal. The modal itself has the promise inside.

If anyone has a good idea how to implement it, it would be nice to heard of.

@wesleycho
Copy link
Contributor Author

I think that sort of support should wait, if it should even be implemented - that would require some further thought on what is the meaning of an isolate $scope inside a modal.

- Correct the implementation of `bindToController` to match Angular with properties on `$scope` being bound on the controller
@wesleycho wesleycho force-pushed the fix/modal-bindToController-impl branch from 7a7ad06 to 4185f64 Compare July 31, 2015 13:55
@wesleycho
Copy link
Contributor Author

@Foxandxss said LGTM, so merging now.

@wesleycho wesleycho closed this in 811bf96 Jul 31, 2015
@wesleycho wesleycho deleted the fix/modal-bindToController-impl branch July 31, 2015 14:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants