Angular Lazy loading not Navigating












1















I'm want to implement Angular lazing loading in my app.



I read through so many books and it seems this the normal way to do it, maybe I missed something important and it's been two days.



https://github.com/kondasMajid/angula-lazy-loading



App-routing-Module.ts



import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
{
path: '',
redirectTo: '',
pathMatch: 'full'
},

{
path: 'home',
loadChildren: './home/home.module#HomeModule'
},
{
path: 'view',
loadChildren: 'app/view/view.module#ViewModule'
}
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }


app.component.html



<button routerLink="/view">view</button>

<router-outlet></router-outlet>


view.module.ts



import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { ViewRoutingModule } from './view-routing.module';
import { RouterModule, Routes } from '@angular/router';
import { ViewComponent } from './view.component';

const routes: Routes = [
{
path: '',
component: ViewComponent
}
];

@NgModule({
declarations: ,
imports: [
CommonModule,
ViewRoutingModule,
RouterModule.forChild(routes)
]
})
export class ViewModule { }


view.component.ts



import { Component, OnInit } from '@angular/core';

@Component({
selector: 'view',
templateUrl: './view.component.html',
styleUrls: ['./view.component.css']
})
export class ViewComponent implements OnInit {
constructor() {}

ngOnInit() {}
}









share|improve this question

























  • view.component.ts import { Component, OnInit } from '@angular/core'; @Component({ selector: 'view', templateUrl: './view.component.html', styleUrls: ['./view.component.css'] }) export class ViewComponent implements OnInit { constructor() { } ngOnInit() { } }

    – Kondas Lamar Jnr
    Nov 25 '18 at 9:59
















1















I'm want to implement Angular lazing loading in my app.



I read through so many books and it seems this the normal way to do it, maybe I missed something important and it's been two days.



https://github.com/kondasMajid/angula-lazy-loading



App-routing-Module.ts



import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
{
path: '',
redirectTo: '',
pathMatch: 'full'
},

{
path: 'home',
loadChildren: './home/home.module#HomeModule'
},
{
path: 'view',
loadChildren: 'app/view/view.module#ViewModule'
}
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }


app.component.html



<button routerLink="/view">view</button>

<router-outlet></router-outlet>


view.module.ts



import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { ViewRoutingModule } from './view-routing.module';
import { RouterModule, Routes } from '@angular/router';
import { ViewComponent } from './view.component';

const routes: Routes = [
{
path: '',
component: ViewComponent
}
];

@NgModule({
declarations: ,
imports: [
CommonModule,
ViewRoutingModule,
RouterModule.forChild(routes)
]
})
export class ViewModule { }


view.component.ts



import { Component, OnInit } from '@angular/core';

@Component({
selector: 'view',
templateUrl: './view.component.html',
styleUrls: ['./view.component.css']
})
export class ViewComponent implements OnInit {
constructor() {}

ngOnInit() {}
}









share|improve this question

























  • view.component.ts import { Component, OnInit } from '@angular/core'; @Component({ selector: 'view', templateUrl: './view.component.html', styleUrls: ['./view.component.css'] }) export class ViewComponent implements OnInit { constructor() { } ngOnInit() { } }

    – Kondas Lamar Jnr
    Nov 25 '18 at 9:59














1












1








1








I'm want to implement Angular lazing loading in my app.



I read through so many books and it seems this the normal way to do it, maybe I missed something important and it's been two days.



https://github.com/kondasMajid/angula-lazy-loading



App-routing-Module.ts



import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
{
path: '',
redirectTo: '',
pathMatch: 'full'
},

{
path: 'home',
loadChildren: './home/home.module#HomeModule'
},
{
path: 'view',
loadChildren: 'app/view/view.module#ViewModule'
}
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }


app.component.html



<button routerLink="/view">view</button>

<router-outlet></router-outlet>


view.module.ts



import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { ViewRoutingModule } from './view-routing.module';
import { RouterModule, Routes } from '@angular/router';
import { ViewComponent } from './view.component';

const routes: Routes = [
{
path: '',
component: ViewComponent
}
];

@NgModule({
declarations: ,
imports: [
CommonModule,
ViewRoutingModule,
RouterModule.forChild(routes)
]
})
export class ViewModule { }


view.component.ts



import { Component, OnInit } from '@angular/core';

@Component({
selector: 'view',
templateUrl: './view.component.html',
styleUrls: ['./view.component.css']
})
export class ViewComponent implements OnInit {
constructor() {}

ngOnInit() {}
}









share|improve this question
















I'm want to implement Angular lazing loading in my app.



I read through so many books and it seems this the normal way to do it, maybe I missed something important and it's been two days.



https://github.com/kondasMajid/angula-lazy-loading



App-routing-Module.ts



import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
{
path: '',
redirectTo: '',
pathMatch: 'full'
},

{
path: 'home',
loadChildren: './home/home.module#HomeModule'
},
{
path: 'view',
loadChildren: 'app/view/view.module#ViewModule'
}
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }


app.component.html



<button routerLink="/view">view</button>

<router-outlet></router-outlet>


view.module.ts



import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { ViewRoutingModule } from './view-routing.module';
import { RouterModule, Routes } from '@angular/router';
import { ViewComponent } from './view.component';

const routes: Routes = [
{
path: '',
component: ViewComponent
}
];

@NgModule({
declarations: ,
imports: [
CommonModule,
ViewRoutingModule,
RouterModule.forChild(routes)
]
})
export class ViewModule { }


view.component.ts



import { Component, OnInit } from '@angular/core';

@Component({
selector: 'view',
templateUrl: './view.component.html',
styleUrls: ['./view.component.css']
})
export class ViewComponent implements OnInit {
constructor() {}

ngOnInit() {}
}






angular lazy-loading






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 '18 at 11:07







Kondas Lamar Jnr

















asked Nov 25 '18 at 9:56









Kondas Lamar JnrKondas Lamar Jnr

249




249













  • view.component.ts import { Component, OnInit } from '@angular/core'; @Component({ selector: 'view', templateUrl: './view.component.html', styleUrls: ['./view.component.css'] }) export class ViewComponent implements OnInit { constructor() { } ngOnInit() { } }

    – Kondas Lamar Jnr
    Nov 25 '18 at 9:59



















  • view.component.ts import { Component, OnInit } from '@angular/core'; @Component({ selector: 'view', templateUrl: './view.component.html', styleUrls: ['./view.component.css'] }) export class ViewComponent implements OnInit { constructor() { } ngOnInit() { } }

    – Kondas Lamar Jnr
    Nov 25 '18 at 9:59

















view.component.ts import { Component, OnInit } from '@angular/core'; @Component({ selector: 'view', templateUrl: './view.component.html', styleUrls: ['./view.component.css'] }) export class ViewComponent implements OnInit { constructor() { } ngOnInit() { } }

– Kondas Lamar Jnr
Nov 25 '18 at 9:59





view.component.ts import { Component, OnInit } from '@angular/core'; @Component({ selector: 'view', templateUrl: './view.component.html', styleUrls: ['./view.component.css'] }) export class ViewComponent implements OnInit { constructor() { } ngOnInit() { } }

– Kondas Lamar Jnr
Nov 25 '18 at 9:59












2 Answers
2






active

oldest

votes


















1














There seems to be a lot of problems with your current implementation:




  1. You've used forChild instead of forRoot in your AppRoutingModule.

  2. In your ViewModule you're doing I don't know what. Ideally, your Routes should be defined in a ViewRoutingModule and then the RouterModule should be exported from there and imported in your ViewModule.

  3. The empty route('') in your AppRoutingModule's Routes config might end up being an infinite loop. So you might want to redirect to somewhere else in that case.


Fixing these two issues should make it work:



AppRoutingModule:



import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
{
path: '',
redirectTo: '/home',
pathMatch: 'full'
},

{
path: 'home',
loadChildren: './home/home.module#HomeModule'
},
{
path: 'view',
loadChildren: 'app/view/view.module#ViewModule'
}
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }


ViewRoutingModule:



import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { RouterModule, Routes } from '@angular/router';
import { ViewComponent } from './view/view.component';

const routes: Routes = [
{
path: '',
component: ViewComponent
}
];

@NgModule({
imports: [
RouterModule.forChild(routes)
],
exports: [
RouterModule
]
})
export class ViewRoutingModule { }


ViewModule:



import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { ViewRoutingModule } from './view-routing.module';
import { RouterModule, Routes } from '@angular/router';
import { ViewComponent } from './view/view.component';

@NgModule({
declarations: [ViewComponent],
imports: [
CommonModule,
ViewRoutingModule
]
})
export class ViewModule { }




Here's a Sample StackBlitz for your ref.






share|improve this answer


























  • Thanks for your reply. i did what you just said, yet i'm not able to navigate to the page.

    – Kondas Lamar Jnr
    Nov 25 '18 at 10:16











  • @KondasLamarJnr, I've updated my answer. There was another issue with your ViewModule. Hopefully, my updated answer should fix your issues.

    – SiddAjmera
    Nov 25 '18 at 10:40













  • thanks alot, but definetly not going well enough for my so i have created a repo on Github , kidly check out for me.. github.com/kondasMajid/angula-lazy-loading

    – Kondas Lamar Jnr
    Nov 25 '18 at 11:05













  • github.com/kondasMajid/angula-lazy-loading

    – Kondas Lamar Jnr
    Nov 25 '18 at 11:07






  • 1





    Please consider using this StackBlitz link to clearly understand: stackblitz.com/edit/angular-xcrhf4

    – SiddAjmera
    Nov 25 '18 at 12:20



















1














Your app.routing.ts should read like this that will be the first change



imports[RouterModule.forRoot(routes)],



Second change is that you need to redirectTo correct path when your route is empty



Try something like this



{
path: '',
redirectTo: '/view',
pathMatch: 'full'
}


Hope these changes will work - happy coding :)



Update:



I think you missed a major missing here - I don't see your AppRoutingModule imported inside your AppModule



@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule //This will do the trick
],
providers: ,
bootstrap: [AppComponent]
})
export class AppModule { }


Try the above changes and import your routing inside your module - Hope it works






share|improve this answer


























  • thanks :) i basically thats not the only bug

    – Kondas Lamar Jnr
    Nov 25 '18 at 11:08











  • I have checked your repo :) i have updated my answer try it and let me know :)

    – Rahul
    Nov 25 '18 at 11:57











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53466389%2fangular-lazy-loading-not-navigating%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














There seems to be a lot of problems with your current implementation:




  1. You've used forChild instead of forRoot in your AppRoutingModule.

  2. In your ViewModule you're doing I don't know what. Ideally, your Routes should be defined in a ViewRoutingModule and then the RouterModule should be exported from there and imported in your ViewModule.

  3. The empty route('') in your AppRoutingModule's Routes config might end up being an infinite loop. So you might want to redirect to somewhere else in that case.


Fixing these two issues should make it work:



AppRoutingModule:



import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
{
path: '',
redirectTo: '/home',
pathMatch: 'full'
},

{
path: 'home',
loadChildren: './home/home.module#HomeModule'
},
{
path: 'view',
loadChildren: 'app/view/view.module#ViewModule'
}
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }


ViewRoutingModule:



import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { RouterModule, Routes } from '@angular/router';
import { ViewComponent } from './view/view.component';

const routes: Routes = [
{
path: '',
component: ViewComponent
}
];

@NgModule({
imports: [
RouterModule.forChild(routes)
],
exports: [
RouterModule
]
})
export class ViewRoutingModule { }


ViewModule:



import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { ViewRoutingModule } from './view-routing.module';
import { RouterModule, Routes } from '@angular/router';
import { ViewComponent } from './view/view.component';

@NgModule({
declarations: [ViewComponent],
imports: [
CommonModule,
ViewRoutingModule
]
})
export class ViewModule { }




Here's a Sample StackBlitz for your ref.






share|improve this answer


























  • Thanks for your reply. i did what you just said, yet i'm not able to navigate to the page.

    – Kondas Lamar Jnr
    Nov 25 '18 at 10:16











  • @KondasLamarJnr, I've updated my answer. There was another issue with your ViewModule. Hopefully, my updated answer should fix your issues.

    – SiddAjmera
    Nov 25 '18 at 10:40













  • thanks alot, but definetly not going well enough for my so i have created a repo on Github , kidly check out for me.. github.com/kondasMajid/angula-lazy-loading

    – Kondas Lamar Jnr
    Nov 25 '18 at 11:05













  • github.com/kondasMajid/angula-lazy-loading

    – Kondas Lamar Jnr
    Nov 25 '18 at 11:07






  • 1





    Please consider using this StackBlitz link to clearly understand: stackblitz.com/edit/angular-xcrhf4

    – SiddAjmera
    Nov 25 '18 at 12:20
















1














There seems to be a lot of problems with your current implementation:




  1. You've used forChild instead of forRoot in your AppRoutingModule.

  2. In your ViewModule you're doing I don't know what. Ideally, your Routes should be defined in a ViewRoutingModule and then the RouterModule should be exported from there and imported in your ViewModule.

  3. The empty route('') in your AppRoutingModule's Routes config might end up being an infinite loop. So you might want to redirect to somewhere else in that case.


Fixing these two issues should make it work:



AppRoutingModule:



import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
{
path: '',
redirectTo: '/home',
pathMatch: 'full'
},

{
path: 'home',
loadChildren: './home/home.module#HomeModule'
},
{
path: 'view',
loadChildren: 'app/view/view.module#ViewModule'
}
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }


ViewRoutingModule:



import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { RouterModule, Routes } from '@angular/router';
import { ViewComponent } from './view/view.component';

const routes: Routes = [
{
path: '',
component: ViewComponent
}
];

@NgModule({
imports: [
RouterModule.forChild(routes)
],
exports: [
RouterModule
]
})
export class ViewRoutingModule { }


ViewModule:



import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { ViewRoutingModule } from './view-routing.module';
import { RouterModule, Routes } from '@angular/router';
import { ViewComponent } from './view/view.component';

@NgModule({
declarations: [ViewComponent],
imports: [
CommonModule,
ViewRoutingModule
]
})
export class ViewModule { }




Here's a Sample StackBlitz for your ref.






share|improve this answer


























  • Thanks for your reply. i did what you just said, yet i'm not able to navigate to the page.

    – Kondas Lamar Jnr
    Nov 25 '18 at 10:16











  • @KondasLamarJnr, I've updated my answer. There was another issue with your ViewModule. Hopefully, my updated answer should fix your issues.

    – SiddAjmera
    Nov 25 '18 at 10:40













  • thanks alot, but definetly not going well enough for my so i have created a repo on Github , kidly check out for me.. github.com/kondasMajid/angula-lazy-loading

    – Kondas Lamar Jnr
    Nov 25 '18 at 11:05













  • github.com/kondasMajid/angula-lazy-loading

    – Kondas Lamar Jnr
    Nov 25 '18 at 11:07






  • 1





    Please consider using this StackBlitz link to clearly understand: stackblitz.com/edit/angular-xcrhf4

    – SiddAjmera
    Nov 25 '18 at 12:20














1












1








1







There seems to be a lot of problems with your current implementation:




  1. You've used forChild instead of forRoot in your AppRoutingModule.

  2. In your ViewModule you're doing I don't know what. Ideally, your Routes should be defined in a ViewRoutingModule and then the RouterModule should be exported from there and imported in your ViewModule.

  3. The empty route('') in your AppRoutingModule's Routes config might end up being an infinite loop. So you might want to redirect to somewhere else in that case.


Fixing these two issues should make it work:



AppRoutingModule:



import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
{
path: '',
redirectTo: '/home',
pathMatch: 'full'
},

{
path: 'home',
loadChildren: './home/home.module#HomeModule'
},
{
path: 'view',
loadChildren: 'app/view/view.module#ViewModule'
}
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }


ViewRoutingModule:



import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { RouterModule, Routes } from '@angular/router';
import { ViewComponent } from './view/view.component';

const routes: Routes = [
{
path: '',
component: ViewComponent
}
];

@NgModule({
imports: [
RouterModule.forChild(routes)
],
exports: [
RouterModule
]
})
export class ViewRoutingModule { }


ViewModule:



import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { ViewRoutingModule } from './view-routing.module';
import { RouterModule, Routes } from '@angular/router';
import { ViewComponent } from './view/view.component';

@NgModule({
declarations: [ViewComponent],
imports: [
CommonModule,
ViewRoutingModule
]
})
export class ViewModule { }




Here's a Sample StackBlitz for your ref.






share|improve this answer















There seems to be a lot of problems with your current implementation:




  1. You've used forChild instead of forRoot in your AppRoutingModule.

  2. In your ViewModule you're doing I don't know what. Ideally, your Routes should be defined in a ViewRoutingModule and then the RouterModule should be exported from there and imported in your ViewModule.

  3. The empty route('') in your AppRoutingModule's Routes config might end up being an infinite loop. So you might want to redirect to somewhere else in that case.


Fixing these two issues should make it work:



AppRoutingModule:



import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
{
path: '',
redirectTo: '/home',
pathMatch: 'full'
},

{
path: 'home',
loadChildren: './home/home.module#HomeModule'
},
{
path: 'view',
loadChildren: 'app/view/view.module#ViewModule'
}
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }


ViewRoutingModule:



import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { RouterModule, Routes } from '@angular/router';
import { ViewComponent } from './view/view.component';

const routes: Routes = [
{
path: '',
component: ViewComponent
}
];

@NgModule({
imports: [
RouterModule.forChild(routes)
],
exports: [
RouterModule
]
})
export class ViewRoutingModule { }


ViewModule:



import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { ViewRoutingModule } from './view-routing.module';
import { RouterModule, Routes } from '@angular/router';
import { ViewComponent } from './view/view.component';

@NgModule({
declarations: [ViewComponent],
imports: [
CommonModule,
ViewRoutingModule
]
})
export class ViewModule { }




Here's a Sample StackBlitz for your ref.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 25 '18 at 10:39

























answered Nov 25 '18 at 10:00









SiddAjmeraSiddAjmera

15.5k31238




15.5k31238













  • Thanks for your reply. i did what you just said, yet i'm not able to navigate to the page.

    – Kondas Lamar Jnr
    Nov 25 '18 at 10:16











  • @KondasLamarJnr, I've updated my answer. There was another issue with your ViewModule. Hopefully, my updated answer should fix your issues.

    – SiddAjmera
    Nov 25 '18 at 10:40













  • thanks alot, but definetly not going well enough for my so i have created a repo on Github , kidly check out for me.. github.com/kondasMajid/angula-lazy-loading

    – Kondas Lamar Jnr
    Nov 25 '18 at 11:05













  • github.com/kondasMajid/angula-lazy-loading

    – Kondas Lamar Jnr
    Nov 25 '18 at 11:07






  • 1





    Please consider using this StackBlitz link to clearly understand: stackblitz.com/edit/angular-xcrhf4

    – SiddAjmera
    Nov 25 '18 at 12:20



















  • Thanks for your reply. i did what you just said, yet i'm not able to navigate to the page.

    – Kondas Lamar Jnr
    Nov 25 '18 at 10:16











  • @KondasLamarJnr, I've updated my answer. There was another issue with your ViewModule. Hopefully, my updated answer should fix your issues.

    – SiddAjmera
    Nov 25 '18 at 10:40













  • thanks alot, but definetly not going well enough for my so i have created a repo on Github , kidly check out for me.. github.com/kondasMajid/angula-lazy-loading

    – Kondas Lamar Jnr
    Nov 25 '18 at 11:05













  • github.com/kondasMajid/angula-lazy-loading

    – Kondas Lamar Jnr
    Nov 25 '18 at 11:07






  • 1





    Please consider using this StackBlitz link to clearly understand: stackblitz.com/edit/angular-xcrhf4

    – SiddAjmera
    Nov 25 '18 at 12:20

















Thanks for your reply. i did what you just said, yet i'm not able to navigate to the page.

– Kondas Lamar Jnr
Nov 25 '18 at 10:16





Thanks for your reply. i did what you just said, yet i'm not able to navigate to the page.

– Kondas Lamar Jnr
Nov 25 '18 at 10:16













@KondasLamarJnr, I've updated my answer. There was another issue with your ViewModule. Hopefully, my updated answer should fix your issues.

– SiddAjmera
Nov 25 '18 at 10:40







@KondasLamarJnr, I've updated my answer. There was another issue with your ViewModule. Hopefully, my updated answer should fix your issues.

– SiddAjmera
Nov 25 '18 at 10:40















thanks alot, but definetly not going well enough for my so i have created a repo on Github , kidly check out for me.. github.com/kondasMajid/angula-lazy-loading

– Kondas Lamar Jnr
Nov 25 '18 at 11:05







thanks alot, but definetly not going well enough for my so i have created a repo on Github , kidly check out for me.. github.com/kondasMajid/angula-lazy-loading

– Kondas Lamar Jnr
Nov 25 '18 at 11:05















github.com/kondasMajid/angula-lazy-loading

– Kondas Lamar Jnr
Nov 25 '18 at 11:07





github.com/kondasMajid/angula-lazy-loading

– Kondas Lamar Jnr
Nov 25 '18 at 11:07




1




1





Please consider using this StackBlitz link to clearly understand: stackblitz.com/edit/angular-xcrhf4

– SiddAjmera
Nov 25 '18 at 12:20





Please consider using this StackBlitz link to clearly understand: stackblitz.com/edit/angular-xcrhf4

– SiddAjmera
Nov 25 '18 at 12:20













1














Your app.routing.ts should read like this that will be the first change



imports[RouterModule.forRoot(routes)],



Second change is that you need to redirectTo correct path when your route is empty



Try something like this



{
path: '',
redirectTo: '/view',
pathMatch: 'full'
}


Hope these changes will work - happy coding :)



Update:



I think you missed a major missing here - I don't see your AppRoutingModule imported inside your AppModule



@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule //This will do the trick
],
providers: ,
bootstrap: [AppComponent]
})
export class AppModule { }


Try the above changes and import your routing inside your module - Hope it works






share|improve this answer


























  • thanks :) i basically thats not the only bug

    – Kondas Lamar Jnr
    Nov 25 '18 at 11:08











  • I have checked your repo :) i have updated my answer try it and let me know :)

    – Rahul
    Nov 25 '18 at 11:57
















1














Your app.routing.ts should read like this that will be the first change



imports[RouterModule.forRoot(routes)],



Second change is that you need to redirectTo correct path when your route is empty



Try something like this



{
path: '',
redirectTo: '/view',
pathMatch: 'full'
}


Hope these changes will work - happy coding :)



Update:



I think you missed a major missing here - I don't see your AppRoutingModule imported inside your AppModule



@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule //This will do the trick
],
providers: ,
bootstrap: [AppComponent]
})
export class AppModule { }


Try the above changes and import your routing inside your module - Hope it works






share|improve this answer


























  • thanks :) i basically thats not the only bug

    – Kondas Lamar Jnr
    Nov 25 '18 at 11:08











  • I have checked your repo :) i have updated my answer try it and let me know :)

    – Rahul
    Nov 25 '18 at 11:57














1












1








1







Your app.routing.ts should read like this that will be the first change



imports[RouterModule.forRoot(routes)],



Second change is that you need to redirectTo correct path when your route is empty



Try something like this



{
path: '',
redirectTo: '/view',
pathMatch: 'full'
}


Hope these changes will work - happy coding :)



Update:



I think you missed a major missing here - I don't see your AppRoutingModule imported inside your AppModule



@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule //This will do the trick
],
providers: ,
bootstrap: [AppComponent]
})
export class AppModule { }


Try the above changes and import your routing inside your module - Hope it works






share|improve this answer















Your app.routing.ts should read like this that will be the first change



imports[RouterModule.forRoot(routes)],



Second change is that you need to redirectTo correct path when your route is empty



Try something like this



{
path: '',
redirectTo: '/view',
pathMatch: 'full'
}


Hope these changes will work - happy coding :)



Update:



I think you missed a major missing here - I don't see your AppRoutingModule imported inside your AppModule



@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule //This will do the trick
],
providers: ,
bootstrap: [AppComponent]
})
export class AppModule { }


Try the above changes and import your routing inside your module - Hope it works







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 25 '18 at 11:57

























answered Nov 25 '18 at 10:22









RahulRahul

1,0992318




1,0992318













  • thanks :) i basically thats not the only bug

    – Kondas Lamar Jnr
    Nov 25 '18 at 11:08











  • I have checked your repo :) i have updated my answer try it and let me know :)

    – Rahul
    Nov 25 '18 at 11:57



















  • thanks :) i basically thats not the only bug

    – Kondas Lamar Jnr
    Nov 25 '18 at 11:08











  • I have checked your repo :) i have updated my answer try it and let me know :)

    – Rahul
    Nov 25 '18 at 11:57

















thanks :) i basically thats not the only bug

– Kondas Lamar Jnr
Nov 25 '18 at 11:08





thanks :) i basically thats not the only bug

– Kondas Lamar Jnr
Nov 25 '18 at 11:08













I have checked your repo :) i have updated my answer try it and let me know :)

– Rahul
Nov 25 '18 at 11:57





I have checked your repo :) i have updated my answer try it and let me know :)

– Rahul
Nov 25 '18 at 11:57


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53466389%2fangular-lazy-loading-not-navigating%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

Refactoring coordinates for Minecraft Pi buildings written in Python