【问题标题】:RESTful route angular route providerRESTful 路由角度路由提供程序
【发布时间】:2013-08-24 19:33:55
【问题描述】:

我想做这样的事情:

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

不幸的是,angular 似乎认为“新”是一个 :playlistId

关于如何实现这个有什么建议吗?

【问题讨论】:

    标签: rest angularjs route-provider


    【解决方案1】:

    尝试更改路线的位置并将 templateUrl 包装在 params 对象中:

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

    我不确定解决方案是否是最终解决方案,但我认为它会起作用,因为 Angular 会按顺序解析路线 而且,顺便说一句,我认为最好为这两个操作设置两个单独的控制器(newplaylistId)。

    【讨论】:

    • 我在 templateUrl 周围没有括号,因为我正在使用咖啡脚本,订单有帮助。
    猜你喜欢
    • 2013-07-18
    • 1970-01-01
    • 2016-05-17
    • 1970-01-01
    • 1970-01-01
    • 2015-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多