Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Component or directive matching' jhi-product-list' element is out of the current Angular module's scope

I have 2 components Home component which is Home Page Product List component which will show me a list of products

Question : When I try to add product-list selector to home.component.html I get this error: Angular Component or directive matching' jhi-product-list' element is out of the current Angular module's scope

product-list.component.ts

import { Component, OnInit } from '@angular/core';
import {ProductService} from "../services/product.service";
import {Product} from "../entities/product";

@Component({
  selector: 'jhi-product-list',
  templateUrl: './product-list.component.html',
  styleUrls: ['./product-list.component.scss']
})
export class ProductListComponent implements OnInit {


  products! : Product[];

  constructor(private productService : ProductService) { }

  ngOnInit(): void {
    this.listProducts();
  }

  listProducts(){
    this.productService.getProductList().subscribe(
        data => {
         this.products = data;
      }
    )
  }

}

product-list.component.html

<p *ngFor="let tempProduct for products">

  {{tempProduct.name}}: {{tempProduct.unitPrice | currency:'USD'}}
</p>

Home.component.html

<div class="row">

<jhi-product-list> </jhi-product-list>

</div>

And Thank you.

like image 917
BAKHALED Ibrahim Avatar asked Sep 11 '25 01:09

BAKHALED Ibrahim


2 Answers

An Angular CLI library is configured in tsconfig.json to refer to it's build output in dist folder. However, dist folder is automatically excluded, which causes generated metadata.json files to be excluded from indexing. Additionally dependencies from such a library are not treated as direct and are excluded from scanning as well.

The workaround is to mark library output in dist as "Not excluded":The image shows how to exclude a folder

1

like image 65
Vlad Druzyakin Avatar answered Sep 13 '25 00:09

Vlad Druzyakin


Such an error may mean that your current module does not see the component. make sure you have correctly imported all your modules and components

like image 38
Jackman Avatar answered Sep 12 '25 22:09

Jackman