Reputation: 31
I can't make the ng-include directive work. I've watched and tried several solutions from stackoverflow but none of them seems to be working. Am I missing something ? Angular works everywhere in the document, except for this. The div is not emebeded in anything.
I am using the foundation framework. Is it possible that it causes the problem ?
Here is the code in my index.html:
<div ng-include="'partials/menu.html'"></div>
I checked and rechecked, I DO have a "partials" folder containing a "menu.html" file...
I have also tried:
<div ng-include src="'partials/menu.html'"></div>
and
<div ng-include="'/partials/menu.html'"></div>
Thanks in advance for any help you could give me !
Upvotes: 1
Views: 395
Reputation: 3107
The issue is the use of single and double quotation, you only need one of them, like this:
<div ng-include="partials/menu.html"></div>
This works as well
<div ng-include='partials/menu.html'></div>
Upvotes: 0
Reputation: 31
Thanks for your answer. I actually figured out what the problem was. It seems you cannot do http requests in chrome on a local file. The console showed an error about that. I tried opening the file in firefox and it worked. I assume this error will not occure once the file is uploaded on a server.
Upvotes: 1
Reputation: 131
You have the correct code here:
<div ng-include=" 'partials/menu.html' "></div>
so it's most likely a path issue. If your partials folder is not inside the same folder as the html file you're calling the partial into, you might need something like '../partials/menu.html'
. You might try creating a simple 'hello world' like partials/test.html with no angular functionality and use that to find the correct path and get your ng-include working.
Upvotes: 2