I want to load a different set of domains at launch if a user is on a subdomain (test.example.com), versus being on a domain (example.com). However, my code keeps defaulting to the domainRoutes without the facility to allow the user to browse (as all the routes don't exist). How can I fix this?
const routes: Routes = [ { matcher: (url) => { if (isOnDomain()) { return { consumed: url }; } return null; }, loadChildren: './modules/website/website.module#WebsiteModule' }, { matcher: (url) => { if (!isOnDomain()) { return { consumed: url }; } return null; }, loadChildren: './modules/main/main.module#MainModule' } ]; const isOnDomain = () => { const full = window.location.host; const parts = full.split('.'); let result = true; if (parts[0] && parts[1] && parts[2]) { result = false; } console.log(result); return result; }; @NgModule({ declarations: [ AppComponent ], imports: [ RouterModule.forRoot(routes) ], providers: [ ], bootstrap: [AppComponent] }) export class AppModule { } -- You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group. To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/angular/3af7c2e2-5a9c-4bba-be42-fad3999fba48%40googlegroups.com.