Angular Lazy loading not Navigating
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
add a comment |
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
view.component.tsimport { 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
add a comment |
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
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
angular lazy-loading
edited Nov 25 '18 at 11:07
Kondas Lamar Jnr
asked Nov 25 '18 at 9:56
Kondas Lamar JnrKondas Lamar Jnr
229
229
view.component.tsimport { 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
add a comment |
view.component.tsimport { 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
add a comment |
2 Answers
2
active
oldest
votes
There seems to be a lot of problems with your current implementation:
- You've used
forChild
instead offorRoot
in your AppRoutingModule. - In your
ViewModule
you're doing I don't know what. Ideally, yourRoutes
should be defined in a ViewRoutingModule and then theRouterModule
should be exported from there and imported in your ViewModule. - The empty route(
''
) in your AppRoutingModule'sRoutes
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.
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 yourViewModule
. 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
|
show 6 more comments
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
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
There seems to be a lot of problems with your current implementation:
- You've used
forChild
instead offorRoot
in your AppRoutingModule. - In your
ViewModule
you're doing I don't know what. Ideally, yourRoutes
should be defined in a ViewRoutingModule and then theRouterModule
should be exported from there and imported in your ViewModule. - The empty route(
''
) in your AppRoutingModule'sRoutes
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.
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 yourViewModule
. 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
|
show 6 more comments
There seems to be a lot of problems with your current implementation:
- You've used
forChild
instead offorRoot
in your AppRoutingModule. - In your
ViewModule
you're doing I don't know what. Ideally, yourRoutes
should be defined in a ViewRoutingModule and then theRouterModule
should be exported from there and imported in your ViewModule. - The empty route(
''
) in your AppRoutingModule'sRoutes
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.
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 yourViewModule
. 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
|
show 6 more comments
There seems to be a lot of problems with your current implementation:
- You've used
forChild
instead offorRoot
in your AppRoutingModule. - In your
ViewModule
you're doing I don't know what. Ideally, yourRoutes
should be defined in a ViewRoutingModule and then theRouterModule
should be exported from there and imported in your ViewModule. - The empty route(
''
) in your AppRoutingModule'sRoutes
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.
There seems to be a lot of problems with your current implementation:
- You've used
forChild
instead offorRoot
in your AppRoutingModule. - In your
ViewModule
you're doing I don't know what. Ideally, yourRoutes
should be defined in a ViewRoutingModule and then theRouterModule
should be exported from there and imported in your ViewModule. - The empty route(
''
) in your AppRoutingModule'sRoutes
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.
edited Nov 25 '18 at 10:39
answered Nov 25 '18 at 10:00
SiddAjmeraSiddAjmera
15.7k31239
15.7k31239
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 yourViewModule
. 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
|
show 6 more comments
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 yourViewModule
. 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
|
show 6 more comments
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
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
add a comment |
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
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
add a comment |
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
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
edited Nov 25 '18 at 11:57
answered Nov 25 '18 at 10:22
RahulRahul
1,1092319
1,1092319
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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