override the NAVIGATE_TO_MANAGE_PROFILE token in the account-config.module

pull/8124/head
mehmet-erim 5 years ago
parent bfe4922b67
commit a376ecb8be

@ -1,12 +1,21 @@
import { ModuleWithProviders, NgModule } from '@angular/core';
import { Injector, ModuleWithProviders, NgModule } from '@angular/core';
import { NAVIGATE_TO_MANAGE_PROFILE } from '@abp/ng.core';
import { ACCOUNT_ROUTE_PROVIDERS } from './providers/route.provider';
import { navigateToManageProfileFactory } from './utils/factories';
@NgModule()
export class AccountConfigModule {
static forRoot(): ModuleWithProviders<AccountConfigModule> {
return {
ngModule: AccountConfigModule,
providers: [ACCOUNT_ROUTE_PROVIDERS],
providers: [
ACCOUNT_ROUTE_PROVIDERS,
{
provide: NAVIGATE_TO_MANAGE_PROFILE,
useFactory: navigateToManageProfileFactory,
deps: [Injector],
},
],
};
}
}

@ -0,0 +1,13 @@
import { Injector } from '@angular/core';
import { RoutesService } from '@abp/ng.core';
import { Router } from '@angular/router';
import { eAccountRouteNames } from '../enums/route-names';
export function navigateToManageProfileFactory(injector: Injector) {
return () => {
const router = injector.get(Router);
const routes = injector.get(RoutesService);
const { path } = routes.find(item => item.name === eAccountRouteNames.ManageProfile);
router.navigateByUrl(path);
};
}
Loading…
Cancel
Save