Angular Play Framework 应用程序中的指令
Angular directive inside Play Framework application
我正在现有的 Play Framework 2.0 应用程序中添加一些 angularJs 函数。
angularjs 文件在 public/
文件夹中提供。一切正常,直到我尝试使用带有单独模板的指令:
指令jsmulti-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
模板?
找到解决方案。
将新路由添加到播放框架 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'
我正在现有的 Play Framework 2.0 应用程序中添加一些 angularJs 函数。
angularjs 文件在 public/
文件夹中提供。一切正常,直到我尝试使用带有单独模板的指令:
指令jsmulti-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
模板?
找到解决方案。
将新路由添加到播放框架 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'