I'm working on ABP framework with Angular UI
I have a route.provider.ts
class that uses ABP router service, so I have something like:
export const APP_ROUTE_PROVIDER=[ {
provide APP_INITIALIZER,
useFactory: configureRoutes,
deps: [RoutesService],
multi: true
}
] function configureRoutes(routesService: RoutesService) {
return (): void=> {
routesService.add([ {
path: '/visits',
name: '::Menu:Visit'
....
}
])
}
}
Then I use this in the app.module.ts
as :
providers: [ APP_ROUTE_PROVIDER]
So, everything works well, but now I have created a new service where I have the current route as:
const url = this.router.url;
I want to know how to retrieve the name property from ABP RoutesService with the current URL. I.E
How can I achieve this if const url = '/visits'
I want to retrieve '::Menu:Visit'
?
You can use Abp RoutesService find() to find the route item and then access its property.
var rt = this.routesService.find( i => i.path ==='/admin/users/add');
console.log(rt.name);