Component imports must be standalone components, directives, pipes, or must be NgModules

Viewed 472

I want to use ngx-avatar in angular standalone component v14.

I use it in the template and I was imported it in the component imports.

But I got error message:

Component imports must be standalone components, directives, pipes, or must be NgModules.

stackblitz

import { AvatarModule } from 'ngx-avatar';

@Component({
  selector: 'my-app',
  standalone: true,
  imports: [AvatarModule, CommonModule],
  template: `
    app works!

    <ngx-avatar class="my-avatar" value="HM"> </ngx-avatar>
  `,
})
export class AppComponent {
  name = 'Angular ' + VERSION.major;
}

I try to solve it using importProvidersFrom but it's not work:

bootstrapApplication(
  AppComponent, {
   providers: [importProvidersFrom(AvatarModule.forRoot())],
  }
);

Any idea how I can make it work?

0 Answers
Related