質問

I would like to do something like this:

$routeProvider 
   .when '/playlists/:playlistId',
      templateUrl: '/partials/playlists/show.html'
   .when '/playlists/new',
      templateUrl: '/partials/playlists/new.html'

unfortunately, angular seems to think "new" is a :playlistId

Any suggestions on how to implement this?

役に立ちましたか?

解決

Try changing your route's positions and wrap the templateUrl in the params object:

$routeProvider 
  .when '/playlists/new',
     {templateUrl: '/partials/playlists/new.html'}
  .when '/playlists/:playlistId',
     {templateUrl: '/partials/playlists/show.html'}

I'm not sure the solution is final but I think it will work since angular parses the routes sequentially and, by the way, I think it's better to have two separate controllers for those two actions (new and playlistId).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top