Arjun
Arjun

Reputation: 1262

Angular; Error: Component NewPharmacyComponent is not part of any NgModule or the module has not been imported into your module

NewPharmacy component is part of the Provider module's declarations array and I have imported Provider module in app.module.ts still I'm getting the error Component NewPharmacyComponent is not part of any NgModule or the module has not been imported into your module.

provider.module.ts

@NgModule({
  declarations: [NewpharmacyComponent],
  imports: [
    CommonModule,
    ProviderRoutingModule
  ]
})
export class ProviderModule { }

app.module.ts

  import {ProviderModule} from './views/provider/provider.module'



   @NgModule({
      imports: [
        BrowserModule,
        HttpClientModule,
        ProviderModule

  ],

I'm not able to figure out the issue.What's wrong with the code?

Upvotes: 0

Views: 121

Answers (1)

Adithya Sreyaj
Adithya Sreyaj

Reputation: 1892

You have to export it to be used in other modules:

@NgModule({
  declarations: [NewpharmacyComponent],
  imports: [
    CommonModule,
    ProviderRoutingModule
  ],
  exports: [NewpharmacyComponent]
})
export class ProviderModule { }

Now the other components will have access to your NewpharmacyComponent.

Upvotes: 3

Related Questions