appcomponent-html:
主页
商品详情
`
productcomponent.ts:
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-product',
templateUrl: './product.component.html',
styleUrls: ['./product.component.css']
})
export class ProductComponent implements OnInit {
private productId: number;
constructor(private routerInfo: ActivatedRoute) { }
ngOnInit() {
this.productId = this.routerInfo.snapshot.queryParamMap['id'];
}
}
报错:
Can't bind to 'queryParamMap' since it isn't a known property of 'a'. ("
主页
][queryParamMap]="{id:1}">商品详情