我想做这样的事情:
$routeProvider
.when '/playlists/:playlistId',
templateUrl: '/partials/playlists/show.html'
.when '/playlists/new',
templateUrl: '/partials/playlists/new.html'
不幸的是,角度似乎认为“新”是一个 :playlistId
关于如何实现这一点的任何建议?
我想做这样的事情:
$routeProvider
.when '/playlists/:playlistId',
templateUrl: '/partials/playlists/show.html'
.when '/playlists/new',
templateUrl: '/partials/playlists/new.html'
不幸的是,角度似乎认为“新”是一个 :playlistId
关于如何实现这一点的任何建议?
尝试更改路线的位置并将 templateUrl 包装在 params 对象中:
$routeProvider
.when '/playlists/new',
{templateUrl: '/partials/playlists/new.html'}
.when '/playlists/:playlistId',
{templateUrl: '/partials/playlists/show.html'}
我不确定解决方案是否是最终解决方案,但我认为它会起作用,因为 angular 会按顺序解析路由,顺便说一下,我认为最好为这两个操作(new
和playlistId
)设置两个单独的控制器。