Angular Structure

import { InjectionToken } from '@angular/core';

export const ROUTES_CONFIG = new InjectionToken('routes.config');

const basePaths = {
customer: 'customer',
//auth: 'auth',
};

const routesNames = {
home: '',
error404: '404',
customer: {
register: 'customer-register',
//detail: ':id',
},
// auth: {
// signUp: 'sign-up',
// logIn: 'log-in',
// },
};

//export const getHeroDetail = (id: string) => `/${basePaths.hero}/${id}`;

export const RoutesConfig: any = {
basePaths,
routesNames,
routes: {
home: `/${routesNames.home}`,
error404: `/${routesNames.error404}`,
customer: {
register: `/${basePaths.customer}/${routesNames.customer.register}`,
//detail: getHeroDetail,
},
// auth: {
// signUp: `/${basePaths.auth}/${routesNames.auth.signUp}`,
// logIn: `/${basePaths.auth}/${routesNames.auth.logIn}`,
// },
},
};
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CustomerRegisterComponent } from './components/customer-register/customer-register.component';
import {CustomerRoutingModule} from "./customer-routing.module";



@NgModule({
declarations: [
CustomerRegisterComponent
],
imports: [
CommonModule, CustomerRoutingModule
]
})
export class CustomerModule { }
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import {RoutesConfig} from "../../configs/routes.config";
import {RouterModule, Routes} from "@angular/router";
import {CustomerRegisterComponent} from "./components/customer-register/customer-register.component";

const customerRoutes = RoutesConfig.routesNames.customer;

const customersRoutes: Routes = [
{ path: customerRoutes.register, component: CustomerRegisterComponent }
];

@NgModule({
declarations: [],
imports: [
CommonModule, RouterModule.forChild(customersRoutes)
]
})
export class CustomerRoutingModule { }
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import {RoutesConfig} from "./configs/routes.config";
import {CustomerRegisterComponent} from "./modules/customer/components/customer-register/customer-register.component";

const routes: Routes = [
// {
// path: RoutesConfig.basePaths.auth,
// loadChildren: () => import('./modules/auth/auth.module').then(m => m.AuthModule),
// },
{
path: 'test',
component: CustomerRegisterComponent
},
{
path: RoutesConfig.basePaths.customer,
loadChildren: () => import('./modules/customer/customer.module').then(m => m.CustomerModule),
},
{ path: '**', redirectTo: RoutesConfig.routes.error404 },
];

@NgModule({
imports: [RouterModule.forRoot(routes,
// {
// initialNavigation : 'enabled',
// scrollPositionRestoration : 'enabled',
// anchorScrolling : 'enabled',
// relativeLinkResolution : 'legacy',
// }

)],
exports: [RouterModule]
})
export class AppRoutingModule { }

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store