-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@Directive @Input('<') setter called before constructor #102
Comments
You shouldn't be accessing $element in constructor according to angular, it should be done in ngOnInit hook |
$element is not the problem, it would be the same with a service it won't be defined in the setter because the setter is called before the constructor. This is a non-sense. The constructor of a class should be called before any other method. because if the instance does not yet exists, I should be able to call any method. Replace |
I see, what angularjs version are you using? There's an issue documented
here angular/angular.js#14206
…On Thu, May 23, 2019, 6:19 PM Kyle ***@***.***> wrote:
$element is not the problem, it would be the same with a service it won't
be defined in the setter because the setter is called before the
constructor. This is a non-sense. The constructor of a class should be
called before any other method. because if the instance does not yet
exists, I should be able to call any method.
Replace $element with $filter in the example above, and you'll get the
same inconsistency: this.$filter is undefined because the setter is
called before the constructor.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#102?email_source=notifications&email_token=AA5HHDBGZIAWMTVEUU53HW3PW2YW5A5CNFSM4HPCX32KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWCSAAQ#issuecomment-495263746>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA5HHDGPVINL4S26L5R7RKTPW2YW5ANCNFSM4HPCX32A>
.
|
I'm in the worst case (1.5.11):
Indeed we should upgrade. Thanks! |
Thanks again for your quick response. We really love your library. ❤️ |
Hello,
I created a directive and noticed that
@Input
setter was called before the class to be constructed.This prevents to use injected dependencies in those setters.
Observed in console:
Expected:
Expected order is the one we get in Angular 2+.
In my opinion, this is a bug. I'm not sure to be able to fix it but I can try to make a pull-request if you're agree to fix it.
Thanks.
The text was updated successfully, but these errors were encountered: