I have setup my routing like that. When user browse to http://localhost:3000, if tries to load Home component. But if user hasn't logged, it redirect user to login component.
@Component({
moduleId: module.id,
selector: 'app',
templateUrl: 'app.component.html',
styleUrls: ['app.component.css'],
directives: [ROUTER_DIRECTIVES],
providers: [UserService]
})
@Routes([
{path: '/', component: HomeComponent},
{path: '/login', component: LoginComponent}
])
export class App implements OnInit {
title: string = 'App Component';
constructor(private router: Router) {}
ngOnInit() {
}
}
Up to that point it is working fine. No issue.
Once user login, it redirect user to home component.
But when I try to load /comp1 with the URL http://localhost:3000/comp1, it looks at second level and try to find /comp1 along with home and login component rather than under 'Home component' and throwing an error that no route '/comp1' found.
I understand that it is an ambiguity issue. Because my home url is '/'. But this is very common that home component sitting at root level of your app and you dont want to add with '/home' or '/main' with your root url for your home component.
Any suggestion how to make this working?