-
Notifications
You must be signed in to change notification settings - Fork 27.4k
bindToController
should work without controllerAs
#15088
Comments
Memory leaks is why. There'd be no reference to destroy the controller when the element died. Besides, the result would simply be an isolated scope. |
@FesterCluck Controllers have the |
Reviewed. You're right. retracted. |
This is probably an oversight (from when making |
Actually, this has been introduced right from the start (787c5a7), when From what I can understand, this restriction was a way to prevent people from misusing the feature (how?), by making sure that the bindings could still be referenced from the template (why?). From the commit message:
I would be fine removing this restriction, unless someone can come up with a good reason not to (that I may have missed). PRs welcome 😄
It seems like it was accidentally removed in 1c13a4f (although it doesn't have any impact, since without |
The requirement for controllerAs might come from the fact that bindToController is most likely / should be used with directive with an isolate scope, which is kind of unlikely to be used without a template. And I just realized, with bindToController, you can have "bindings" to a directive that doesn't create an isolate scope: http://plnkr.co/edit/INKSyrVyT11I8L8F19Dw?p=preview |
How is it possible that you just realized this? It was you who authored #13681. :) |
That doesn't mean I understood the implications. It was just words. 😁
|
Hi there! This feature has broken all the applications that were using this inside their directives. The bindToController property is not binding to the controller anymore. Can you guys fix this? Thanks |
I don't see how this could have broken anything (since it only allowed a usecase that would throw an error). Can you please create a new issue and be more specific about what has been broken (e.g. provide a reproduction)? Thanks |
Do you want to request a feature or report a bug?
bug
What is the current behavior?
If I create a directive with
bindToController
and withoutcontrollerAs
, I get$compile:noident
: Controller identifier is required.If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (template: http://plnkr.co/edit/tpl:yBpEi4).
http://plnkr.co/edit/lhg3NJABx2DQWnF56rzg
What is the expected behavior?
controllerAs
shouldn't be required. If the directive doesn't create a scope, addingcontrollerAs
to it will pollute the outer scope.What is the motivation / use case for changing the behavior?
Use case: directives that have controller bindings, but have neither a template nor an own scope. What do they need
controllerAs
for?Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.
1.5.8
The text was updated successfully, but these errors were encountered: