Play Framework应用程序中的Angular指令

Play Framework应用程序中的Angular指令

问题描述:

我在现有的Play Framework 2.0应用程序中添加了一些angularJs函数。Play Framework应用程序中的Angular指令

angularjs文件在public/文件夹内提供。一切正常,直到我试图使用带有分隔模板的指令:

指令js multi-charts.js和指令模板multi-charts.html都放在同一个目录components/directives中。 所以对于文件的完整路径将是:

  • public/components/directives/multi-charts.js
  • public/components/directives/multi-charts.html

的问题是,我不能”达到预定可使用templateUrl指令里面的模板文件。

的指令:

app.directive('multiCharts', ['chartService', function(chartService){ 
    return { 
     restrict: 'EACM', 
     templateUrl: 'components/directives/multi-charts.html', 
     replace: true, 
     link: function (scope, elem, attrs) { 
     } 
    }}]); 

运行应用程序模板是无法实现的:

GET http://localhost:9000/company/components/directives/multi-chart.html 404 (Not Found) 

更改内部templateUrl的路径不改变错误。

我错过了一些东西,有没有办法在由内部Play Framework网络服务器提供的指令中引用html模板?

+0

多charts.html =多chart.html你错过了或者在这个例子中只是一个错字? – stackg91

+0

错字,谢谢 – Atropo

找到解决方案。 添加一个新的路线到播放框架routes文件:

# Map static resources from the /public folder to the /assets URL path 
GET  /assets/*file        controllers.Assets.at(path="/public", file) 

我能够在到达模板:

templateUrl: '../assets/js/angular/directives/multi-charts.html'