小编Val*_*lov的帖子

访问路由参数 - angular 8

嘿,试图用产品建立网站,但我无法从 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)

routes angular route-parameters angular8

2
推荐指数
1
解决办法
5607
查看次数

标签 统计

angular ×1

angular8 ×1

route-parameters ×1

routes ×1