Is it possible to use a partial-static parameter in angular 2 routing? I'm going to explain:
Now I'm using classic parameter like this:
const routes: Routes = [
{
path: ':type/fine.html',
pathMatch: 'full',
redirectTo: ':type/fine'
}
But I would be able to use something like this:
const routes: Routes = [
{
path: 'static-:type/fine.html',
pathMatch: 'full',
redirectTo: 'static-:type/fine'
}
To be able to redirect exactly to static-{{parameterValue}}/fine
.
Is it possible?
Passing data between the Angular component through the route is very easy after the release of the Angular 7.2 version. NavigationExtras provides an easy way to pass data from the template and from the component. Small components are always good to manage code maintainability.
What is an activated route? The Angular Docs define the ActivatedRoute as. A service that is provided to each route component that contains route specific information such as route parameters, static data, resolve data, global query params and the global fragment.
pathMatch = 'prefix' tells the router to match the redirect route when the remaining URL begins with the redirect route's prefix path. pathMatch: 'full' means, that the whole URL path needs to match and is consumed by the route matching algorithm.
After many tries i've reached the knowledge that is impossible to do something like it. So i've implemented a completely different approach with a routing-guard following this example:
http://www.sparkbit.pl/angular-2-route-guards-real-life-example/
Just answering for anyone who will find same problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With