Skip to content

Dynamic Routing with AOT #5754

@sam-rusty

Description

@sam-rusty

I'm working on a app where i need to have a logic in routing to decide which page should be the home page, it works fine with JIT but with AOT. Here is how my code looks like

       let subdomain = environment.production ? window.location.host.replace('www.', '').split('.')[0] : 'sahiwal';
       let districts = {sahiwal:'121', faisalabad:'122'}
        export const routes: Routes = [
            {
                path: '',
                component: MasterComponent,
                children: [
                    {
                        path: districts[subdomain] ? '' : 'home',
                        loadChildren: './home.module#HomeModule',
                        data: {title: 'سجاگ'}
                    }, {
                        path: subdomain === domain ? '' : 'main',
                        loadChildren: './main.page.module#MainPageModule',
                        data: {title: 'سجاگ'}
                    },
                    {
                        path: 'news',
                        loadChildren: './news.module#NewsModule',
                        data: {title: 'خبر سجاگ'}
                    }, {
                        path: subdomain === 'features' ? '' : 'features',
                        loadChildren: './archive.module#ArchiveModule',
                        data: {title: 'خبر سجاگ'}
                    }
            }
        ];

Versions

@angular/cli: 1.0.0
node: 6.9.1
os: darwin x64
@angular/common: 4.0.1
@angular/compiler: 4.0.1
@angular/animations: 4.0.1
@angular/core: 4.0.1
@angular/forms: 4.0.1
@angular/http: 4.0.1
@angular/platform-browser: 4.0.1
@angular/platform-browser-dynamic: 4.0.1
@angular/platform-server: 4.0.1
@angular/router: 4.0.1
@angular/cli: 1.0.0
@angular/compiler-cli: 4.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions