-
Notifications
You must be signed in to change notification settings - Fork 40
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
getting reference to the new lazy loaded element #70
Comments
Hi @TheILPlace ! Why not just use If not possible (maybe they are always different) then you can always fall back to |
thanks for your reply. even if resolving to querySelector, the question is... in which lifecycle hook to catch it ? maybe you should consider adding an event/hook that will fire after the new dynamic component is created , so we could use that ! |
@TheILPlace that's a good point, emitting custom |
@tomastrajan |
@TheILPlace sounds good! Looking forward to the PR and wish you happy holidays (if applicable 😉) |
@tomastrajan so we have 2 options:
i've tested scenario 1 and it works quite well. and as opposed to what i've suggested above, i cannot return a reference to the Component , but rather the html element what do you think ? |
Hi @TheILPlace ! Thank you for all the effort and research. It's really unfortunate that there seems to be no really nice way of doing this on the library side. I would rather not add some pretty sub-optimal ways of doing this in the lib itself. One thing that comes to mind is then elements providing loaded event themselves. eg What about, instead of using subject if we passed in callback, eg |
@tomastrajan |
@tomastrajan there is a still problem with the change detection cycle <ax-lazy-element *axLazyElementDynamic="customElement.selector, setting a breakpoint in the "elementCreated" function, i get a reference to the created element by using:
putting this in a setTimeout with then show the actual value of the data property :( |
@TheILPlace thank you for trying this out! Now when I think about it, it seems reasonable that the binding was NOT executed yet when the element was loaded as that is really the first thing that happens and Angular runs after. Maybe we could specify some other flag if the |
@tomastrajan about documentation - from experience, people first will try it, then find bindings are not present, then create an issue, and they you will point them to the docs :) what about my suggestion to have a subject in the loader-service ? expose it via a function like: |
@tomastrajan What do you think ? |
@TheILPlace service sounds good, but wasn't there some issue with multiple elements / tags or smthing?
But if this can be resolved then it would be really nice! |
hi,
i am using *axLazyElementDynamic to lazy load dynamic component.
very similar to the dynamic demo in the docs. the configuration is an Array retrieved from the server.
the problem i am facing:
i need to grab a hold on the created element in my class, in order to set some attributed, and register to event emitters.
i've tried using ViewChildren, but cannot get a reference to the element. i've tried various lifecycle hooks (oninit, aftercontentini, afterviewinit) but the viewchildren variable is always undefined.
you're help is appriciated.
The text was updated successfully, but these errors were encountered: