嘿,试图用产品建立网站,但我无法从 productsComponent 到 ProductDetailsComponent 获取数据。请帮我。
在我的 Product.ts 我有:
export class Product {
id: number;
name: string;
constructor(id: number, name: string) {
this.id = id;
this.name = name;
}
}
Run Code Online (Sandbox Code Playgroud)
在我的 ProductsComponenet 我有:
import { Component } from '@angular/core';
import { Product } from '../services.service';
@Component({
selector: 'app-services',
templateUrl: './services.component.html',
styleUrls: ['./services.component.css']
})
export class ServicesComponent {
public products: Product[] = [
new Product(1, "Product 001"),
new Product(2, "Product 002"),
new Product(3, "Product 003"),
new Product(4, "Product 004"),
new Product(5, "Product …Run Code Online (Sandbox Code Playgroud)