-1
Hello, my problem is this, I need to leave the dynamic whenever I play a different value in navigation, this is my code:
editarForm() {
const valor = ('X');
this.router.navigate(['/' + valor + '/edit/'], { relativeTo: this.route });
}
when I throw any "value" in this function the result is the below:
core.js:15723 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'edit'
Error: Cannot match any Routes. URL Segment: 'Edit' At Applyredirects.push.. /node_modules/@angular/router/fesm5/router.js.Applyredirects.noMatchError (router.js:2469) At Catchsubscriber.selector (router.js:2450) At Catchsubscriber.push.. /node_modules/rxjs/_esm5/Internal/Operators/catchError.js.Catchsubscriber.error (catchError.js:34) At Mapsubscriber.push.. /node_modules/rxjs/_esm5/Internal/Subscriber.js.Subscriber. _error (Subscriber.js:80) At Mapsubscriber.push.. /node_modules/rxjs/_esm5/Internal/Subscriber.js.Subscriber.error (Subscriber.js:60) At Mapsubscriber.push.. /node_modules/rxjs/_esm5/Internal/Subscriber.js.Subscriber. _error (Subscriber.js:80) At Mapsubscriber.push.. /node_modules/rxjs/_esm5/Internal/Subscriber.js.Subscriber.error (Subscriber.js:60) At Mapsubscriber.push.. /node_modules/rxjs/_esm5/Internal/Subscriber.js.Subscriber. _error (Subscriber.js:80) At Mapsubscriber.push.. /node_modules/rxjs/_esm5/Internal/Subscriber.js.Subscriber.error (Subscriber.js:60) At tapsubscriber.push.. /node_modules/rxjs/_esm5/Internal/Operators/tap.js.Tapsubscriber. _error (tap.js:61) resolveat Promise (zone.js:831) resolveat Promise (zone.js:788) at zone.js:892 At Zonedelegate.push.. /node_modules/zone.js/dist/zone.js.Zonedelegate.invokeTask (zone.js:423) At Object.onInvokeTask (core.js:17289) At Zonedelegate.push.. /node_modules/zone.js/dist/zone.js.Zonedelegate.invokeTask (zone.js:422) At Zone.push.. /node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195) drainat IcroTaskQueue (zone.js:601) at Zonetask.push.. /node_modules/zone.js/dist/zone.js.Zonetask.invokeTask [as invoke] (zone.js:502) at invokeTask (zone.js:1744)
By error the problem does not seem to be in the variable, 2 things: use template strings to make the code more readable
/${valor}/edit
, and try to put a url that exists to see if the page is loaded.– LeAndrade