concept ProductComponent in category angular

appears as: ProductComponent, ProductComponent, ProductComponent
Angular Development with Typescript, Second Edition

This is an excerpt from Manning's book Angular Development with Typescript, Second Edition.

  • ng g c product will generate four files for a new product component in the src/app/product directory and add the ProductComponent class to the declarations property of @NgModule.
  • ng g c product -is --it --spec false will generate a single file, product.component.ts, with inlined styles and template and no test in the src/app/product directory, and add ProductComponent to the declarations property of @NgModule.
  • Listing 5.1. ProductService injected into ProductComponent
    @Component({
      providers: [ProductService]                       #1
     })
    class ProductComponent {
      product: Product;
    
      constructor(productService: ProductService) {     #2
    
        this.product = productService.getProduct();     #3
       }
    }
    Figure 5.3. Injecting ProductService into ProductComponent

    Remember that the ProductComponent is responsible for rendering the product view that includes ProductDetailComponent and ProductSuggestionComponent with the grid of suggested products, and you modified the code of both components.