8

I have a template that is inserted via ng-include and that template also has an ng-include. The inner ng-incude is not being shown. Why?

Main Template:

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

views/outer.html:

<div ng-repeat="item in items">
    // Stuff
    <div ng-include src="'views/inner.html'"></div> // not being shown
    // More stuff
</div>
Chris Paterson
  • 1,129
  • 5
  • 21
  • 31
  • Have you checked the console to see if you have any JavaScript errors? An error might prevent the remainder of the Angular (or any JS) code from running. – Matt Cashatt Jan 07 '14 at 03:32
  • Also see the console for path issues. Make sure the partial exist at the location – Chandermani Jan 07 '14 at 03:35

2 Answers2

4

The code you posted should work so the problem is probably situated somewhere else.

One of the reasons could be that a JavaScript error is thrown somewhere else or that no items are found in the scope. Make sure to check the browser console.

Here is a working version of your code for your convenience:

http://plnkr.co/edit/pCTInrtITqHraC1hPyZH?p=preview

Hope that helps!

jvandemo
  • 13,046
  • 2
  • 23
  • 18
0

ng-include is a directive. Your view/outer.html should do like this:

$parent.items

Because directive not inherit parent automatically.

ihsanberahim
  • 1,051
  • 12
  • 14