无法在 angular 2 中导航所需的 url
unable to navigate the the required url in angular 2
我创建了路径并且这些路径工作正常,因为我想导航详细信息页面。
ex:if 用户输入 id,点击按钮,它应该导航到 id 的详细信息页面。
有这样的组件,
export class ComplaintStatusComponent implements OnInit {
constructor(private _complaintService:ComplaintService,private router:Router) { }
complaints={};
ngOnInit() {
this.getCompliants();
}
getComplaintDetails(complntId){
this._complaintService.getCompliants(complntId).subscribe(data => console.log(data));
this.router.navigate(['/complaintstatus', this.complntId]);
}
getCompliants():void{
}
}
服务是:
export class ComplaintService{
private _url:string ="http://192.168.1.58:8000/app/complaint/complaintstatus"
constructor(private _http:Http){}
getCompliants(complntId){
return this._http.get(this._url + '/' + complntId).map((response:Response)=>response.json());
}
}
getComplaintDetails(complntId){
this._complaintService.getCompliants(complntId).subscribe(data => console.log(data));
this.router.navigate(['/complaintstatus', complntId]);
}
去掉你的id前面的this
我创建了路径并且这些路径工作正常,因为我想导航详细信息页面。 ex:if 用户输入 id,点击按钮,它应该导航到 id 的详细信息页面。
有这样的组件,
export class ComplaintStatusComponent implements OnInit {
constructor(private _complaintService:ComplaintService,private router:Router) { }
complaints={};
ngOnInit() {
this.getCompliants();
}
getComplaintDetails(complntId){
this._complaintService.getCompliants(complntId).subscribe(data => console.log(data));
this.router.navigate(['/complaintstatus', this.complntId]);
}
getCompliants():void{
}
}
服务是:
export class ComplaintService{
private _url:string ="http://192.168.1.58:8000/app/complaint/complaintstatus"
constructor(private _http:Http){}
getCompliants(complntId){
return this._http.get(this._url + '/' + complntId).map((response:Response)=>response.json());
}
}
getComplaintDetails(complntId){
this._complaintService.getCompliants(complntId).subscribe(data => console.log(data));
this.router.navigate(['/complaintstatus', complntId]);
}
去掉你的id前面的this