Transitioning from ng1 using angular-avatar, handling ngUpgrade downgradeComponent situation
jpike88 opened this issue · comments
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 (#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?
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
angular-avatar is a completely different library
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:
- make a supermodule for my app and ngx-avatar, and import both into that
- Copy the entire codebase into our project, and sidestep
avatar.module.ts
( we did this )
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.
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
fixed in version 3.5.0
Great, that does the trick. Thanks. Sorry false alarm