1

I have a problem at the navigation with angluar navigation.

I have a route like the following

     {
            path: 'truckdetails/:lieferNr',
            component: TruckDetailComponent,
            data: { state: 'truckdetail' },
            canActivate: [AuthguardService]
        },

If I using the routing like this

this.router.navigate(['truckdetails', delivery.LIEFER_NR]);

if I am using the following term

this.router.navigate(['truckdetails', response.data]);

I get the error that he can't find the route. I think it worked before I update anglular to the new version. But know I get error

Error: Cannot match any routes. URL Segment: 'truckdetails;lieferNr=00179324'

The Response also containing the lieferNr

{timestamp: 1530014875302, status: 200, message: "QRCode Scanned", data: {…}}
data :{lieferNr: "00179324"}
message : "QRCode Scanned"
status : 200
timestamp : 1530014875302
5
  • Could you please specify all of your app routes in your app-routing.module.ts file? I am asking because you might have another route that might be blocking the defined route. Commented Jun 26, 2018 at 12:43
  • Is response.data an object {lieferNr: 00179324}? That won't resolve to the route truckdetails/00179324; as you're seeing, it resolves to the route truckdetails, which isn't specified, with optional parameters ;lieferNr=00179324. You need response.data.lieferNr. Commented Jun 26, 2018 at 12:44
  • @jonrsharpe, yes it is an objetct out of an http request. Commented Jun 26, 2018 at 13:01
  • I'd suggest reading angular.io/guide/router, it talks about the various ways you can pass parameters to routes and the different outcomes. Commented Jun 26, 2018 at 13:03
  • you forgot the slash sign truckdetails/ Commented Jun 26, 2018 at 13:23

1 Answer 1

1

response.data contains {lieferNr: "00179324"} which once serialized gives lieferNr=00179324 when you want only 00179324. Then use:

this.router.navigate(['truckdetails', response.data.lieferNr]);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.