0

I'm trying to create a html fragement that should lateron serve as an image slider. So far it only contains a test div element:

slider.html:
<div>TEST</div>

I'm trying to include this in my index.html as follows:

<div ng-include src="slider.html"></div>

Result: I don't see the test div. Why?

4
  • 1
    ng-include="'slider.html'" Commented Aug 10, 2015 at 13:44
  • @ajmajmajma You need to put single quotes around the string constant. Commented Aug 10, 2015 at 13:47
  • Already answered here:<br> stackoverflow.com/a/31609423/5052704 Hope this helps. Commented Aug 10, 2015 at 13:47
  • Already answered here <br> stackoverflow.com/a/31609423/5052704 Hope this helps. Commented Aug 10, 2015 at 13:49

3 Answers 3

3

Try this:

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

When using a path in ng-include you need to enclose it with single quotes, since it expects an expression.

From the docs:

If the source is a string constant, make sure you wrap it in single quotes, e.g. src="'myPartialTemplate.html'".

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

1 Comment

@membersound don't forget to mark a given answer as answered
1
<ng-include src="'slider.html'"></ng-include>

or

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

Comments

0

You can include another html like below:

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

It has already been answered here:
https://stackoverflow.com/a/31609423/5052704

Hope this helps.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.