marklagendijk / ui-router.stateHelper

A helper module for AngularUI Router, which allows you to define your states as an object tree.
MIT License
235 stars 40 forks source link

How can I set parameters with stateHelper #3

Closed sivathangeswaran closed 10 years ago

sivathangeswaran commented 10 years ago

I want to have a route defined like below.

  1. /home/contacts - default contacts page loads
  2. /home/contacts/123 - the contact detail of id 123 will be loaded

I use below configuration, but $stateParams.id shows undefined

{
    name: "home",
    url: "/home",
    templateUrl: "/templates/uiRouterDemoHome.html",
    controller: "uiRouterDemoController",
    children: [
        {
            name: "contacts",
            url: "/contacts",
            templateUrl: "/templates/contactsList.html",
            controller: "contactListController",
            children: [
                {
                    name: ":id",
                    url: "/:id",
                    templateUrl: "uiRouterDemo/templates/contactsList.html",
                    controller: "contactListController"
                }
            ]
        }
    ]
}
marklagendijk commented 10 years ago

I would use 'details' as name instead of ':id'. Apart from that I see nothing wrong with this. Let me know if you still have problems with this.