0
votes

Situation

I started an app with Playframework (Scala) and AngularJS v1.3.

(Exactly the template Play Silhouette Angular Seed)

Goal

Loading difference templates using ng-include or a directive.

Problem

Always that I put a reference in Angular code, it doesn't work.

Example:

<div ng-include="'/tpl.html'"></div>
<script type="text/ng-template" id="/tpl.html">
   Content of the template.
</script>

Result: works!!

Now, if I put the template tpl.html in a file in the same directory:

<div ng-include="'tpl.html'"></div>

Result: Doesn't work!! (And in other directories, I tried all the possible routes...)

The same problem occurs in directives, if I put the template inside the directory it works well, but if I try to put in another file it doesn't work.

Question

I used Angular in other projects and never occurs something like this. I think that this happens because Scala (language of Playframework) needs to be compiled and the files .scala.html are converted in .html.

  • How can I create some templates .html and then with ng-include put the correct reference?
1
template file path should be relative to your index page. - dhavalcengg
Just I tried this again and doesn't work. ng-include="'view1.html'" and view.html file in the same directory that index.html... - Aral Roca
view1.html sorry, not view.html. - Aral Roca
What play version is it? 2.4? - Mon Calamari
2.1 I think. Is the default version from the template that I used: github.com/mohiva/play-silhouette-angular-seed - Aral Roca

1 Answers

0
votes

The root directory is the same that index.htmlfile (path: ui/app).

If the file view1.html is in the path ui/app, the ng-include will be like this:

<div ng-include="'./view1.html'"></div>

Because ui/app is the root path.