Search code examples
javascriptangularjsurl-routingdashboard

AngularJS Routing to Multiple Start Pages


I am trying to make an app where I have a home page, and a dashboard that has a separate route. If I use ng-route, I will only be able to add stuff onto my homepage.

Basically, I'm asking how can I have it so when I got to http://example.com/#/features And then go to http://example.com/#/dashboard/control , be able to still use ng-route on my dashboard page, instead of injecting it into my home page. Is there something I can add to my app.js, or will I have to make an entirely new app.js for my dashboard (which is what I was thinking I have to do)

I hope this made sense, I've always had trouble explaining things like this :P .

Cheers!


Solution

  • instead of using ng-route use ui-router,ui-router will provide you better control over navigation

    Its can be structured like

    .state(login)
    .state(login.forgotpassword)
    .state(dashboard)
    .state(dashboard.list)
    .state(dashboard.user)
    

    as you see you can have navigation control over two different state.