1

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?

1 Answer 1

1

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>

Sign up to request clarification or add additional context in comments.

2 Comments

Yes but it's in another html file. In this way it doesn't recognize the id of the template.. If myTemplate was in the same page of the ng-inlcude then yes, it worked. But in this way nope
Ok, try pulling the template http out into a separate file (with no script tags around it). Then ng-include a path to that file in both places you need to use it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.