HaithemMosbahi / ngx-avatar

Universal avatar component for angular 2+ applications makes it possible to fetch / generate avatar from different sources
MIT License
236 stars 92 forks source link

Transitioning from ng1 using angular-avatar, handling ngUpgrade downgradeComponent situation #62

Closed jpike88 closed 5 years ago

jpike88 commented 5 years ago

It's not immediately clear how to use this with ngUpgrade, as usually 3rd party components provide the component itself, not a module.

That way, I can use that component in entryComponents, and declare this code in my AppModule:

    public ngDoBootstrap() {
        angular.module('').directive('fields', downgradeComponent({
            component: FieldsComponent
        }) as angular.IDirectiveFactory);
    }

I tried this PR (https://github.com/HaithemMosbahi/ngx-avatar/pull/48) but the problem is that if I export the component separately, it seems to be an issue:

Component is part of the declaration of 2 modules

How can I easily solve this?

jpike88 commented 5 years ago

Relevant PR? https://github.com/HaithemMosbahi/ngx-avatar/pull/48

HaithemMosbahi commented 5 years ago

Hi, I am not sure I understand the issue here ! This component was not implemented for ng1, it's for Angular 2+. The pull request that you mentioned is meant for supporting Angular Elements and not NgUpgrade

HaithemMosbahi commented 5 years ago

angular-avatar is a completely different library

jpike88 commented 5 years ago

angular-avatar is a completely different library

I'm aware of that, just giving you background

This component was not implemented for ng1, it's for Angular 2+.

But you didn't implement a component, you implemented a module that exports a single component. This makes accessing the component directly for entryComponents to be impossible, unless I either:

https://angular.io/api/upgrade/static/downgradeComponent

Zero ng1 knowledge is needed

I forked your demo, to show you... app.module.ts is all you need to look at:

https://stackblitz.com/edit/ngx-avatar-demo-obfbwn

I have a whole bunch of other 3rd party ng2 components doing this and they work fine, this is the only one that presents issues.

HaithemMosbahi commented 5 years ago

Now I understand the problem, the AngularComponent class is needed in order to be able to downgrade it and use it ing ng1. I will export AvatarComponent class in the next version

HaithemMosbahi commented 5 years ago

fixed in version 3.5.0

jpike88 commented 5 years ago

Great, that does the trick. Thanks. Sorry false alarm