When reloading the page with a routes child route it does not load the component due to the nature of the component, but it does not even route back to the main route. First, Is this supposed to be handled by me or is take care of by angular?
Update:
Hashstrategy did not work the way expected for second question.
In case of first I have route /users/... and a child /users/vote . When reloading /users it goes to /login but when reloading /users/vote it does not reload to that component (naturally) and does not go to /login as well
Update
@RouteConfig([
{path: '/vote', component: VoteComponent, name: 'VoteCmp',useAsDefault: true },
{path: '/getapproval', component: GetapprovalComponent, name: 'GetapprovalCmp' },
{path: '/userresults', component: ResultsComponent, name: 'UserresultsCmp' }
])
@Component({
selector: 'users',
....
directives: [ROUTER_DIRECTIVES, RouterLink]
})
export class UsersComponent{
constructor(private _userdetails: Userdetails, private _router: Router){
if (this._userdetails.usertypeDetails() === "" || this._userdetails.isLoggedin() === false){
this._router.navigate( ['HomeCmp'] );
}
if(this._userdetails.usertypeDetails() === 'admin'){
this._router.navigate( ['AdminCmp'] );
}
}
}
My vote component
@Component({
selector: 'vote',
template: `<div>Vote Component</div>`,
})
export class VoteComponent {
constructor(private _userdetails: Userdetails, private _router: Router){
if (this._userdetails.usertypeDetails() === "" || this._userdetails.isLoggedin() === false){
this._router.navigate( ['HomeCmp'] );
}
if(this._userdetails.usertypeDetails() === 'admin'){
this._router.navigate( ['AdminCmp'] );
}
}
}
My boot.ts has this
bootstrap(MainComponent,[Userdetails,ROUTER_PROVIDERS, Location, provide(LocationStrategy, {useClass: HashLocationStrategy}, ROUTER_BINDINGS, bind(APP_BASE_HREF).toValue('/')]);