have a scenario,if user enters one number and submit it should navigate to that id and display the details.
when i navigate url,it's showing something like this
complaintstatus/TS0000031?complntId=TS0000031
Detail view code:
export class ComplaintDetailComponent implements OnInit {
id:number;
private sub:any;
complntId : any;
constructor(private ComponentService:ComplaintService,private route:ActivatedRoute){
}
ngOnInit() {
this.sub= this.route.params.subscribe((params:Params)=>{
this.ComponentService.getCompliants(params['complntId'])
});
console.log(this.sub);
}
user enters id code :
export class ComplaintStatusComponent {
constructor(private router:Router){}
getComplaintDetails(complntId){
this.router.navigate(['/complaintstatus', complntId]);
}
}
and one more question,how can i send user enter id to another component.
and service code:
export class ComplaintService{
private _url:string ="http://192.168.0.106:8000/app/complaint/complaintstatus"
constructor(private _http:Http){}
getCompliants(complntId){
return this._http.get(this._url + '/' + complntId).map((response:Response)=>response.json());
}
}
routing Module:
const routes: Routes = [
{path:'complaintregistration',component:ComplaintRegistartionComponent},
{path:'complaintstatus',component:ComplaintStatusComponent},
{path:'complaintstatus/:complntId',component:ComplaintDetailComponent}
];