Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

$componentController doesn't bind properties when component uses ES6 controller class #14437

Closed
kycook opened this issue Apr 14, 2016 · 0 comments

Comments

@kycook
Copy link

kycook commented Apr 14, 2016

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
Bindings set up with $componentController are undefined when using a ES6 class as the controller. See an example at http://jsbin.com/qaxivowuni/1/edit?js,output. Switching from the Es6Controller to the Es5Controller causes the binding to be defined.

What is the expected behavior?
The bindings are defined regardless of how the controller class is created.

What is the motivation / use case for changing the behavior?
Unable to use ES6 features.

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.
Angular 1.5 / Chrome 49.0.2623.87 / Mac OS 10.11.4

@gkalpak gkalpak added this to the 1.5.5 milestone Apr 14, 2016
gkalpak added a commit to gkalpak/angular.js that referenced this issue Apr 14, 2016
…trollers (e.g. class-based)

The decorated version of `$controller` is able to assign bindings to a controller instance prior to
instantiation, emulating the behavior of `$compile` with directive controllers.

There are cases, that the actual controller instance is different than the pre-populated one (e.g.
when the controller constructor function returns a value or when the controller is an ES2015 Class).
While `$compile` accounts for such situation, by re-asigning the bindings after the controller has
been instantiated, `ngMock`'s `$controller` didn't.

This commit fixes it, by re-applying the bindings if the actual controller instance is different
than the original one (similar to how `$compile` would do it).

Fixes angular#14437
gkalpak added a commit to gkalpak/angular.js that referenced this issue Apr 14, 2016
…trollers (e.g. class-based)

The decorated version of `$controller` is able to assign bindings to a controller instance prior to
instantiation, emulating the behavior of `$compile` with directive controllers.

There are cases, that the actual controller instance is different than the pre-populated one (e.g.
when the controller constructor function returns a value or when the controller is an ES2015 Class).
While `$compile` accounts for such situation, by re-asigning the bindings after the controller has
been instantiated, `ngMock`'s `$controller` didn't.

This commit fixes it, by re-applying the bindings if the actual controller instance is different
than the original one (similar to how `$compile` would do it).

Fixes angular#14437
gkalpak added a commit to gkalpak/angular.js that referenced this issue Apr 15, 2016
…trollers (e.g. class-based)

The decorated version of `$controller` is able to assign bindings to a controller instance prior to
instantiation, emulating the behavior of `$compile` with directive controllers.

There are cases, that the actual controller instance is different than the pre-populated one (e.g.
when the controller constructor function returns a value or when the controller is an ES2015 Class).
While `$compile` accounts for such situation, by re-asigning the bindings after the controller has
been instantiated, `ngMock`'s `$controller` didn't.

This commit fixes it, by re-applying the bindings if the actual controller instance is different
than the original one (similar to how `$compile` would do it).

Fixes angular#14437
@petebacondarwin petebacondarwin modified the milestones: 1.5.5, 1.5.6 Apr 18, 2016
@Narretz Narretz modified the milestones: 1.5.6, 1.5.7 May 27, 2016
@gkalpak gkalpak closed this as completed in 96266b9 Jun 7, 2016
gkalpak added a commit that referenced this issue Jun 7, 2016
…trollers (e.g. class-based)

The decorated version of `$controller` is able to assign bindings to a controller instance prior to
instantiation, emulating the behavior of `$compile` with directive controllers.

There are cases, that the actual controller instance is different than the pre-populated one (e.g.
when the controller constructor function returns a value or when the controller is an ES2015 Class).
While `$compile` accounts for such situation, by re-asigning the bindings after the controller has
been instantiated, `ngMock`'s `$controller` didn't.

This commit fixes it, by re-applying the bindings if the actual controller instance is different
than the original one (similar to how `$compile` would do it).

Fixes #14437

Closes #14439
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants