Atlas91
Atlas91

Reputation: 5904

Angularjs include a template from another page

I've got a template in a html page to include in another page. This is because the two html are very long and i can't use only one page to both. So i decided to separate them. Summary this is my case:

in partials/template.html

<script type="text/ng-template" id="myTemplate">
    myTemplate..
</script>

and in partials/my_layout.html

<ng-include src="'./partials/template.html'"></div>

But it's not working now. Nothing is showing when the page is loaded. How can i access to the template of the template.html page?

Upvotes: 1

Views: 1487

Answers (1)

Anthony Patton
Anthony Patton

Reputation: 596

Its likely a relative path issue. The path should be from index.html to your template, not the path from one template to another. Try something like this:

<ng-include src="'partials/template.html'"></div>

EDIT

I just noticed this was a script template. The id that you give the template is the key that you can use to access it in the src of the ng-include. Try this:

<ng-include src="'myTemplate'"></div>

Upvotes: 1

Related Questions