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

onLoad hook #30

Open
bori87 opened this issue Oct 23, 2019 · 8 comments
Open

onLoad hook #30

bori87 opened this issue Oct 23, 2019 · 8 comments

Comments

@bori87
Copy link

bori87 commented Oct 23, 2019

how to notify component that element is loaded?

@tomastrajan
Copy link
Member

Can you please elaborate a bit more about the use case? The *axLazyElement directive enables us to use standard Angular template bindings, and also things like @ViewChild so why would we want to know that ? Stuff should just work as any other standard Angular component in the template ?

@BossOz
Copy link

BossOz commented Feb 18, 2020

hello @tomastrajan,

so, if I need the instance of the lazy-component I need just that?

<ax-lazy-element #dynComponent 
                 *axLazyElementDynamic="this.componentSelector, url: this.componentJsLocation">
</ax-lazy-element>

With the ViewChild

@ViewChild("dynComponent", { static: false }) componentIstance;

@tomastrajan
Copy link
Member

Hi @BossOz ! It all depends on the use case. Could you describe what are you trying to achieve?

Your current snippet uses dynamic element which will then change once loaded ao I dont know what would happen at that case as I did not try that yet.

For <some-element #myRef *axLazyDirective> it should work, you might need { read: ElementRef } as its not a component.

@BossOz
Copy link

BossOz commented Feb 18, 2020

I need something like this because I need to initialize my elements using a standard methods.

For example:
componentIstance.intializeValue(objParams, settings);

@tomastrajan
Copy link
Member

@BossOz so your element is not an Angular element but standard web component ? Cuz this library focuses on that other use case to make it possible to <some-element #myRef *axLazyDirective [initialValue]="initialValue"> which was usually not the case and everything had to be done imperatively...

In your case, even if @ViewChild() worked you still would NOT know when it was actually populated... I think adding optional event for loaded would not be too bad and will look into how to add it.

@BossOz
Copy link

BossOz commented Aug 12, 2020

@tomastrajan hello dude!
Any news on that?

@tomastrajan
Copy link
Member

Hi @BossOz !

This is now available! Check out API docs (search for "afterLoad")

@omanzelli
Copy link

omanzelli commented May 4, 2021

Hi @tomastrajan,

Is there a way to use this hook inline like so?
<some-element *axLazyElement="url; module: true; loadingTemplate: loading; afterLoadHook: elementLoaded">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants