There are a few different ways you could do this..
The quickest way would be to use a BehaviorSubject that you can use to set and get data from..
a simple implementation would be
Create a product service product.service.ts inside this service you need to create a behaviorSubject and create a set method
product.service.ts
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class ProductService
productListSource = new BehaviorSubject<any>(null); // creates the BehaviorSubject
// You will use this method to store the data
setProductList(data: any) {
this.productListSource.next(data)
}
}
then what you want to do is in your product-list.component
product-list.component.ts
import { ProductService } from '...';
// ...
constructor(
private _product: ProductService
) {}
getProduct() {
this.productList = data;
this._product.setProductList(this.productList);
}
then wherever you want to get this information from you can do the following
component
import { ProductService } ...
// ...
constructor(
private _product: ProductService
) {}
getProducts() {
this._product.productListSource.subscribe(data => {
// do stuff here
})
}
This way, you can use the productList data anywhere in your app, and its not stuck within your product component as it would be if you used the @Input() @Output() method
Now If you plan on updating and manipulating this data a lot and using it from a few different components you should consider using an @ngrx/store. you can learn more about this here angular ngrx a clean and clear introduction