const routes: Routes = [
{ path: 'x', component: xComponent },
{ path: 'y', component: yComponent },
{ path: 'zComponent', component: zComponent }
];
If I write in the url x small it will direct me to the component page, if I write X Capital it will say not valid url.
How to make the url insensitive Case
The routes in Angular are case sensitive. In the routeconfig, you have specified the url path as "product".
That's because the routes that are configured using UI-Router are case sensitive. To make route insensitive, all you have to do is to inject $urlMatcherFactoryProvider service into the config() function and call caseInsensitive(true) function.
Angular Router supports multiple outlets in the same application. A component has one associated primary route and can have auxiliary routes. Auxiliary routes enable developers to navigate multiple routes at the same time.
Two options .. 1. create 1 URLSerializer Class
import { DefaultUrlSerializer, UrlTree } from '@angular/router';
export class LowerCaseUrlSerializer extends DefaultUrlSerializer {
parse(url: string): UrlTree {
return super.parse(url.toLowerCase());
}
}
And in your app.module.ts
providers: [
{
provide: UrlSerializer,
useClass: LowerCaseUrlSerializer
}
],
Option 2: Simple workaround in your route file.
{ path: '/home', redirectTo: ['/Home'] },
{ path: '/Home', component: HomeComponent, name: 'Home' },
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