Product service:
product:IProduct;
products:IProduct[] = [];
id:number;
constructor(private productSevice:ProductService, private route: ActivatedRoute) {
}
ngOnInit(): void {
this.id= parseInt(this.route.snapshot.paramMap.get('id'));
console.log(this.productSevice.products)
this.productSevice.getById(this.id).subscribe(data => {
this.product = data;
console.log(data)
})
console.log(this.product)
}
product:
product:IProduct = null;
id:any;
it doesn't matter what i'm trying, product is null!
when i'm doing console.log in the subscribe i can see the data! but the product still null. | -> I tried that also onInit same result -<