Angular 6 nested children routing not rendering view
I am stuck in a place where the navigation works, but view is not working basically one component is mapped to two different routes:
Component is example.component.ts
Routes are
http://localhost:4200/manager/nav/example
http://localhost:4200/nav/valuation
Have two different modules and have there own routes defined
Navigation mecahnism: when user hits manager it loads its own component and then user can navigate to manager>nav and from nav user can naviagte to manager>nav>example
manager.routing.ts
{ path: 'manager', component: ManagerComponent , children:[
{ path: '', component: PortfolioManagerComponent },
{ path: 'nav', component: NavComponent},children: [
{ path: 'example', component: component:ExampleComponent}
] }
]
}
http://localhost:4200/manager/nav
http://localhost:4200/manager/nav/example
Route changed but view not render bascially its on manager view not on example view
But when i use the route nav and than hit example it loads the original page and nav has its own module and routing
nav.routing.ts
{ path: 'nav', component: NavComponent, children: [
{ path: '', component: PropertyComponent},
{ path: 'example, ', component:ExampleComponent}
]
Showing right views
When i use the route http://localhost:4200/manager/nav/example till http://localhost:4200/manager/nav the view changes and when I naviagte to http://localhost:4200/manager/nav/example the same view remains its is not loading the view but route changes
You can see first two Images to view the routing and last two images the right view
angular angular-routing angular-guards
add a comment |
I am stuck in a place where the navigation works, but view is not working basically one component is mapped to two different routes:
Component is example.component.ts
Routes are
http://localhost:4200/manager/nav/example
http://localhost:4200/nav/valuation
Have two different modules and have there own routes defined
Navigation mecahnism: when user hits manager it loads its own component and then user can navigate to manager>nav and from nav user can naviagte to manager>nav>example
manager.routing.ts
{ path: 'manager', component: ManagerComponent , children:[
{ path: '', component: PortfolioManagerComponent },
{ path: 'nav', component: NavComponent},children: [
{ path: 'example', component: component:ExampleComponent}
] }
]
}
http://localhost:4200/manager/nav
http://localhost:4200/manager/nav/example
Route changed but view not render bascially its on manager view not on example view
But when i use the route nav and than hit example it loads the original page and nav has its own module and routing
nav.routing.ts
{ path: 'nav', component: NavComponent, children: [
{ path: '', component: PropertyComponent},
{ path: 'example, ', component:ExampleComponent}
]
Showing right views
When i use the route http://localhost:4200/manager/nav/example till http://localhost:4200/manager/nav the view changes and when I naviagte to http://localhost:4200/manager/nav/example the same view remains its is not loading the view but route changes
You can see first two Images to view the routing and last two images the right view
angular angular-routing angular-guards
My advice is to use lazy loading and the link below may give you the answer: stackoverflow.com/questions/49621578/…. I use this lazy loading throughout my large scale application eCommerce similar to yours. See my profile. Good luck in finding the solutions to your issues.
– harold_mean2
Nov 23 '18 at 6:15
add a comment |
I am stuck in a place where the navigation works, but view is not working basically one component is mapped to two different routes:
Component is example.component.ts
Routes are
http://localhost:4200/manager/nav/example
http://localhost:4200/nav/valuation
Have two different modules and have there own routes defined
Navigation mecahnism: when user hits manager it loads its own component and then user can navigate to manager>nav and from nav user can naviagte to manager>nav>example
manager.routing.ts
{ path: 'manager', component: ManagerComponent , children:[
{ path: '', component: PortfolioManagerComponent },
{ path: 'nav', component: NavComponent},children: [
{ path: 'example', component: component:ExampleComponent}
] }
]
}
http://localhost:4200/manager/nav
http://localhost:4200/manager/nav/example
Route changed but view not render bascially its on manager view not on example view
But when i use the route nav and than hit example it loads the original page and nav has its own module and routing
nav.routing.ts
{ path: 'nav', component: NavComponent, children: [
{ path: '', component: PropertyComponent},
{ path: 'example, ', component:ExampleComponent}
]
Showing right views
When i use the route http://localhost:4200/manager/nav/example till http://localhost:4200/manager/nav the view changes and when I naviagte to http://localhost:4200/manager/nav/example the same view remains its is not loading the view but route changes
You can see first two Images to view the routing and last two images the right view
angular angular-routing angular-guards
I am stuck in a place where the navigation works, but view is not working basically one component is mapped to two different routes:
Component is example.component.ts
Routes are
http://localhost:4200/manager/nav/example
http://localhost:4200/nav/valuation
Have two different modules and have there own routes defined
Navigation mecahnism: when user hits manager it loads its own component and then user can navigate to manager>nav and from nav user can naviagte to manager>nav>example
manager.routing.ts
{ path: 'manager', component: ManagerComponent , children:[
{ path: '', component: PortfolioManagerComponent },
{ path: 'nav', component: NavComponent},children: [
{ path: 'example', component: component:ExampleComponent}
] }
]
}
http://localhost:4200/manager/nav
http://localhost:4200/manager/nav/example
Route changed but view not render bascially its on manager view not on example view
But when i use the route nav and than hit example it loads the original page and nav has its own module and routing
nav.routing.ts
{ path: 'nav', component: NavComponent, children: [
{ path: '', component: PropertyComponent},
{ path: 'example, ', component:ExampleComponent}
]
Showing right views
When i use the route http://localhost:4200/manager/nav/example till http://localhost:4200/manager/nav the view changes and when I naviagte to http://localhost:4200/manager/nav/example the same view remains its is not loading the view but route changes
You can see first two Images to view the routing and last two images the right view
angular angular-routing angular-guards
angular angular-routing angular-guards
asked Nov 23 '18 at 5:24
Kumail HussainKumail Hussain
380626
380626
My advice is to use lazy loading and the link below may give you the answer: stackoverflow.com/questions/49621578/…. I use this lazy loading throughout my large scale application eCommerce similar to yours. See my profile. Good luck in finding the solutions to your issues.
– harold_mean2
Nov 23 '18 at 6:15
add a comment |
My advice is to use lazy loading and the link below may give you the answer: stackoverflow.com/questions/49621578/…. I use this lazy loading throughout my large scale application eCommerce similar to yours. See my profile. Good luck in finding the solutions to your issues.
– harold_mean2
Nov 23 '18 at 6:15
My advice is to use lazy loading and the link below may give you the answer: stackoverflow.com/questions/49621578/…. I use this lazy loading throughout my large scale application eCommerce similar to yours. See my profile. Good luck in finding the solutions to your issues.
– harold_mean2
Nov 23 '18 at 6:15
My advice is to use lazy loading and the link below may give you the answer: stackoverflow.com/questions/49621578/…. I use this lazy loading throughout my large scale application eCommerce similar to yours. See my profile. Good luck in finding the solutions to your issues.
– harold_mean2
Nov 23 '18 at 6:15
add a comment |
1 Answer
1
active
oldest
votes
I believe your problem is you use Angular's default path matching strategy, which is prefix. It means that Angular will use the first route it finds in your router module that starts with the specified segment of your route.
And an empty path is a special case as all paths starts with an empty path. So in this example nav and example both start with an empty path and Angular will navigate to the component that is associated with empty path and that is PortfolioManagerComponent.
{ path: 'manager', component: ManagerComponent , children:[
{ path: '', component: PortfolioManagerComponent },
{ path: 'nav', component: NavComponent},children: [
{ path: 'example', component: component:ExampleComponent}
] }
What you need to do is changing your matching strategy to full by adding the pathMatch attribute to your route:
{ path: 'manager', component: ManagerComponent , children:[
{ path: '', pathMatch: 'full', component: PortfolioManagerComponent },
{ path: 'nav', component: NavComponent},children: [
{ path: 'example', component: component:ExampleComponent}
] }
More info in the docs: https://angular.io/api/router/Routes#matching-strategy
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%2f53441038%2fangular-6-nested-children-routing-not-rendering-view%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I believe your problem is you use Angular's default path matching strategy, which is prefix. It means that Angular will use the first route it finds in your router module that starts with the specified segment of your route.
And an empty path is a special case as all paths starts with an empty path. So in this example nav and example both start with an empty path and Angular will navigate to the component that is associated with empty path and that is PortfolioManagerComponent.
{ path: 'manager', component: ManagerComponent , children:[
{ path: '', component: PortfolioManagerComponent },
{ path: 'nav', component: NavComponent},children: [
{ path: 'example', component: component:ExampleComponent}
] }
What you need to do is changing your matching strategy to full by adding the pathMatch attribute to your route:
{ path: 'manager', component: ManagerComponent , children:[
{ path: '', pathMatch: 'full', component: PortfolioManagerComponent },
{ path: 'nav', component: NavComponent},children: [
{ path: 'example', component: component:ExampleComponent}
] }
More info in the docs: https://angular.io/api/router/Routes#matching-strategy
add a comment |
I believe your problem is you use Angular's default path matching strategy, which is prefix. It means that Angular will use the first route it finds in your router module that starts with the specified segment of your route.
And an empty path is a special case as all paths starts with an empty path. So in this example nav and example both start with an empty path and Angular will navigate to the component that is associated with empty path and that is PortfolioManagerComponent.
{ path: 'manager', component: ManagerComponent , children:[
{ path: '', component: PortfolioManagerComponent },
{ path: 'nav', component: NavComponent},children: [
{ path: 'example', component: component:ExampleComponent}
] }
What you need to do is changing your matching strategy to full by adding the pathMatch attribute to your route:
{ path: 'manager', component: ManagerComponent , children:[
{ path: '', pathMatch: 'full', component: PortfolioManagerComponent },
{ path: 'nav', component: NavComponent},children: [
{ path: 'example', component: component:ExampleComponent}
] }
More info in the docs: https://angular.io/api/router/Routes#matching-strategy
add a comment |
I believe your problem is you use Angular's default path matching strategy, which is prefix. It means that Angular will use the first route it finds in your router module that starts with the specified segment of your route.
And an empty path is a special case as all paths starts with an empty path. So in this example nav and example both start with an empty path and Angular will navigate to the component that is associated with empty path and that is PortfolioManagerComponent.
{ path: 'manager', component: ManagerComponent , children:[
{ path: '', component: PortfolioManagerComponent },
{ path: 'nav', component: NavComponent},children: [
{ path: 'example', component: component:ExampleComponent}
] }
What you need to do is changing your matching strategy to full by adding the pathMatch attribute to your route:
{ path: 'manager', component: ManagerComponent , children:[
{ path: '', pathMatch: 'full', component: PortfolioManagerComponent },
{ path: 'nav', component: NavComponent},children: [
{ path: 'example', component: component:ExampleComponent}
] }
More info in the docs: https://angular.io/api/router/Routes#matching-strategy
I believe your problem is you use Angular's default path matching strategy, which is prefix. It means that Angular will use the first route it finds in your router module that starts with the specified segment of your route.
And an empty path is a special case as all paths starts with an empty path. So in this example nav and example both start with an empty path and Angular will navigate to the component that is associated with empty path and that is PortfolioManagerComponent.
{ path: 'manager', component: ManagerComponent , children:[
{ path: '', component: PortfolioManagerComponent },
{ path: 'nav', component: NavComponent},children: [
{ path: 'example', component: component:ExampleComponent}
] }
What you need to do is changing your matching strategy to full by adding the pathMatch attribute to your route:
{ path: 'manager', component: ManagerComponent , children:[
{ path: '', pathMatch: 'full', component: PortfolioManagerComponent },
{ path: 'nav', component: NavComponent},children: [
{ path: 'example', component: component:ExampleComponent}
] }
More info in the docs: https://angular.io/api/router/Routes#matching-strategy
answered Nov 23 '18 at 12:55
lastminute84lastminute84
363
363
add a comment |
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%2f53441038%2fangular-6-nested-children-routing-not-rendering-view%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
My advice is to use lazy loading and the link below may give you the answer: stackoverflow.com/questions/49621578/…. I use this lazy loading throughout my large scale application eCommerce similar to yours. See my profile. Good luck in finding the solutions to your issues.
– harold_mean2
Nov 23 '18 at 6:15