【问题标题】:angular ui router with play framework 2.4带有播放框架 2.4 的 Angular ui 路由器
【发布时间】:2016-10-08 17:36:52
【问题描述】:

我想从播放路由切换到角度路由,所以我想使用角度 ui 路由器。我对如何使用“templateUrl”有疑问。我发现了这个example,它适用于具有动态路线的 play 2.5:

# Dynamic part of the url
GET         /views/$template<.+>.html        controllers.ApplicationController.view(template)

所以在 play 2.4 中我没有这个功能,并且我尝试在 templateUrl 中放置一个链接(我在我的路由文件中定义)但它不起作用

【问题讨论】:

    标签: playframework angular-ui-router


    【解决方案1】:

    这取决于您使用 Play with Angular 的方式。第一个选项是在 Play 中集成 Angular 的东西(就像你提到的例子中一样)。根据tutorial,路由入口应该是这样的:

      GET    /*file    controllers.Assets.versioned(path="/public", file: Asset)
    

    您还应该遵循本教程的其余说明。

    另一种方法是将 Angular 开发为一个独立的项目。在这种情况下,Play 只是一个 REST 服务器。它们之间的集成是通过将所有 Angular 内容定位到公共文件夹并添加静态 Play 路由来实现的。 Play 根本不知道 Angular。

    应该是这样的:

    1. 将所有 Angular 文件放在 Play 项目的 public 文件夹下。文件可以按任何目录结构组织。

    2. 在公用文件夹下的某处创建一个静态 index.html。这将是 Angular 东西的入口点。

    3. index.html 的路由添加到 routes 中。如果 index.html 直接在 public 文件夹中,则路由如下:

      GET /       controllers.Assets.at(path="/public", file ="index.html")
      
    4. 将 Angular 文件的路由添加到 routes

      GET /*file  controllers.Assets.at(path="/public", file)
      

    你可以看到更多细节here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-08
      • 1970-01-01
      • 1970-01-01
      • 2015-11-21
      • 1970-01-01
      相关资源
      最近更新 更多