Reputation: 938
what I can do with this:
I have:
appPath/courses
- list
appPath/courses/:id
- route with param
appPath/courses/add
- route to add new course
And when I type appPath/courses/add
it going to appPath/courses/:id
.when
clausule.
How to fix that?
.when("/courses", {
templateUrl: "App/courses/index/view.html",
controller: "CoursesIndexCtrl"
})
.when("/courses/add", {
templateUrl: "App/courses/add/view.html",
controller: "AddCourseCtrl"
})
.when("/courses/:id", {
templateUrl: "App/courses/details/view.html",
controller: "CourseDetailsCtrl"
})
Upvotes: 1
Views: 25
Reputation: 3622
/courses/:id
and /courser/add
are quite the same for the router. you will ending up overwriting either one or another.
give up on one othe those routes and adopt a longer path, for example:
/courses/add
/courses/detail/:id
Upvotes: 1
Reputation: 2304
Just change the order:
appPath/courses - list
appPath/courses/add - route to add new course
appPath/courses/:id - route with param
Upvotes: 1