alexandesigner
alexandesigner

Reputation: 25

Angular ngRoute not working parameters

Guys I got a problem (lack of experience) in ngRouter, I can work with the parameters in routes with two ex levels:

editoria/:itemId

.when('/editoria/:itemId',{
        templateUrl:"templates/editoria/index.html",
        controller:'EditoriaCtrl'
})

however, must use a primary route

/:editoriaId

.when('/:itemId',{
        templateUrl:"templates/editoria/index.html",
        controller:'EditoriaCtrl'
    })

I hope I have been clear, hehe

how do I do?

Upvotes: 0

Views: 158

Answers (1)

New Dev
New Dev

Reputation: 49590

Yes, with ngRoute, you specify the path (starting from base) to match the route so you need to specify it fully.

If you were to use ui.router - a much more feature-rich alternative to ngRoute - then you could have a parent-child relationship of states:

.state("editoria", {
  abstract: true,
  url: "/editoria"
})
.state("editoria.item", {
  url: "/:itemId",
  templateUrl: "templates/editoria/index.html",
  controller: "EditoriaCtrl"
})

Upvotes: 1

Related Questions