In angular to hide the parent routing?

Good day to all. Have a diagram of the route:

const routes: Routes = [
 { path: ", component: RegularComponent },
 { path: 'crm', component: LoginComponent ,
 children: [
 { path: 'newlead', component: NewLeadComponent, canActivate: [AuthGuard] },
 { path: 'leadlist', component: LeadListComponent, canActivate: [AuthGuard],
 children: [
 { path: ':id', component: LeadPageComponent, canActivate: [AuthGuard] },
]
},
]},
];


Where there are child elements, with parole in the component LoginComponent I insert the tag <router-outlet></router-outlet>in order to display the child element.

Everything works fine, except that turning in a child element are displayed and parent and child. How to make parent element was hidden?
March 19th 20 at 08:23
1 answer
March 19th 20 at 08:25
Solution
Subscribe to activatedRouter, check it and set the hide flag. Well, the content in the parent under the ngIf.
But if there is such a need is likely something you are doing wrong architectural.
So what's the problem then I can not understand, I think developed have developed have provided my problem - skylar_Rau commented on March 19th 20 at 08:28
@skylar_Rau, I don't see the problem, the parent and the need to display its content.
But if a parent you do not need, then do it immediately without it
{ path: 'crm/newlead', component: NewLeadComponent, canActivate: [AuthGuard] }

of course it should be higher than path: 'crm'

Do what you want to do, doing something different. You have RegularComponent should be checking on the login, and if not then redirect to the LoginComponent.
He LoginComponent no children should contain. - abbigail_Homenick commented on March 19th 20 at 08:31
@abbigail_Homenickwhy it is implemented as guard canactivate, a request is made to the server, backing validates the cookie and compares with the session in the database. If everything is OK the canactivate function returns true if something else, it is false and redirect to the login.
Maybe I did wrong, but I stuck to the official documentation of angular.
I did as you stated in the beginning, after I altered to it now as described in my question.
For me the implementation you propose is not very correct, the path will have to change in each url, that's all pornography.
And with ngIf, too crooked, do not right like that.
Thank you - skylar_Rau commented on March 19th 20 at 08:34
@skylar_Rau, well, that's in the guard and put a redirect. Or in the parent component.
And you have a functional user component attached to a window login. Nothing strange is not it? - abbigail_Homenick commented on March 19th 20 at 08:37
@abbigail_Homenick, Well, I just thought to implement somewhat differently, if a person goes to */crm, if he has cookies, it redirects to */crm/dashboard, if not then appears the login) - skylar_Rau commented on March 19th 20 at 08:40

Find more questions by tags Angular