Skip to content

Repository files navigation

Missing Provider shown in wrong standalone component (reproduction scenario)

You can fix it here:

@Component({
  selector: 'app-some-child-component',
  standalone: true,
  imports: [
    CommonModule,
  ],
  template: `<p>SomeChildComponent works!</p>`,
  changeDetection: ChangeDetectionStrategy.OnPush,
  providers: [DatePipe]  // <-- This should be suggested
})
export class SomeChildComponent implements OnInit {
  private date = inject(DatePipe);

  ngOnInit() {
    console.log(this.date.transform(new Date));
  }
}

or here:

@Component({
  selector: 'app-some-routed-component',
  standalone: true,
  imports: [
    CommonModule,
    SomeChildComponent
  ],
  template: `<app-some-child-component>`,
  changeDetection: ChangeDetectionStrategy.OnPush,
  providers: [DatePipe]  // <-- Angular suggests adding provider here but is this the right place?
})
export class SomeRoutedComponent { }

or here:

export const appConfig: ApplicationConfig = {
  providers: [
    provideZoneChangeDetection({ eventCoalescing: true }),
    provideRouter(routes),
    DatePipe // also possible but depends on the use case
  ]
};

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages