Skip to content
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

upgradeAdapter.upgradeNg1Component $element #10597

Closed
AlexKhymenko opened this issue Aug 9, 2016 · 4 comments
Closed

upgradeAdapter.upgradeNg1Component $element #10597

AlexKhymenko opened this issue Aug 9, 2016 · 4 comments

Comments

@AlexKhymenko
Copy link

I'm submitting a ... (check one with "x")

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
When u try to upgrade directive that uses $element service and use it in Angular2 component the element will have NO children nodes.
Expected/desired behavior
When u try to upgrade component that uses $element service the element will have children nodes.

What is the expected behavior?
When u try to upgrade component that uses $element service the element will have children nodes.

What is the motivation / use case for changing the behavior?
To be available to update directives that uses $element service and use them in hybrid application

Please tell us about your environment:

  • Angular version: 2.0.0-rc.4
  • Browser: [all ]
  • Language: [all | TypeScript 1.8 ]
@guojenman
Copy link

@AlexKhymenko You have to wait after the $onInit is called on your controller. Trying to access $element before that, will result in what you're seeing

function MyController($element) {
  console.log($element.children()) // no children here
  this.$onInit = function() {
    console.log($element.children()) // here they are
  }
}

@AlexKhymenko
Copy link
Author

Thank you will try!!!

@dbpieter
Copy link

@AlexKhymenko @guojenman

This does not work and it appears to be a bug when upgrading an ng1 component.

Whereas a pure ng1 component has $element available in $onInit. An upgraded ng1 component does not have $element available in $onInit until after sometime.

Logged #13912

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants