1. 程式人生 > >angular4 開發記錄

angular4 開發記錄

init imp for ber this details truct model struct

1,傳值問題

page setValue: [routerLink]="[‘/product-details‘, product.id]">

ts seValue: this.router.navigate([‘/product-details‘, id]);

ts getVaue:

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 number

// In a real app: dispatch action to load the details here.
});
}
ngOnDestroy() {
this.sub.unsubscribe();
}
}

2,model

export class Gundam{
id:number;
name:String;
}

import {Gundam} form ‘../model/gundam‘;
export class GUNDAMS:Gundam[]=[]

angular4 開發記錄