1,傳值問題app
page setValue: [routerLink]="['/product-details', product.id]"> this
ts seValue: this.router.navigate(['/product-details', id]);spa
ts getVaue: orm
constructor(private route: ActivatedRoute) {}
export class LoanDetailsPage implements OnInit, OnDestroy {
id: number;
private sub: any;
constructor(private route: ActivatedRoute) {}
ngOnInit() {
this.sub = this.route.params.subscribe(params => {
this.id = +params['id']; // (+) converts string 'id' to a numberrouter
// In a real app: dispatch action to load the details here.
});
}
ngOnDestroy() {
this.sub.unsubscribe();
}
}get
2,modelstring
export class Gundam{
id:number;
name:String;
}it
import {Gundam} form '../model/gundam';
export class GUNDAMS:Gundam[]=[]io