Skip to content

Instantly share code, notes, and snippets.

@jsinglet
Last active February 16, 2021 19:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsinglet/2593561cc976a76c9b6775d22a21afc1 to your computer and use it in GitHub Desktop.
Save jsinglet/2593561cc976a76c9b6775d22a21afc1 to your computer and use it in GitHub Desktop.
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { LoginService, getLoginService } from './login.service';
import { TenantService, Tenant } from '../tenant/tenant.service';
import { Client1loginService } from './client1login.service';
import { Client2loginService } from './client2login.service';
import { RouterModule, Routes, Router } from "@angular/router";
@NgModule({
declarations: [],
imports: [
CommonModule, RouterModule
],
providers: [
{
provide: LoginService,
useFactory: getLoginService,
deps: [TenantService, Client1loginService, Client2loginService]
}
]
})
export class LoginModule {
constructor(private router: Router, private tenantService: TenantService) {
// configure the routes.
let appRoutes: Routes = [];
if (this.tenantService.getTenant() == Tenant.CLIENT1) {
console.log("Configuring CLIENT1 Login Components.");
appRoutes = [
// your routes here
];
} else if (this.tenantService.getTenant() == Tenant.CLIENT2) {
console.log("Configuring CLIENT2 Login Components.");
appRoutes = [
// your routes here.
];
}
appRoutes.forEach(e => this.router.config.unshift(e));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment