Using Component as a Directive

There are few things to consider while using component as a directive.

Step 1
Use 'product-list.component.ts' selector as a HTML tag in 'app.component.ts'



Step 2
Under 'app.module.ts' we have to import ProductListComponent along with its relative path.
import { ProductListComponent } from './products/product-list.component';

Also, under 'declarations' we have to import ProductListComponent class we had created in 'product-list.component.ts'
@NgModule({
  declarations: [
    AppComponent,
    ProductListComponent
  ],
  imports: [
    BrowserModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})

Share this

Related Posts