AngularJs: ng-include does not work when placed inside ng-view tag

I am loading an html page via an angular route inside ng-view. The page I am loading contains an ng-include tag pointing to another html file.

I tried all the syntax below =

<div ng-include src="'some.jsp'"></div>
<div ng-include="'login.jsp'"></div>
<div ng-include src="include.url"></div>

Does not work. But if I put the same tag outside the ng-view its working fine.

What am I doing wrong?

+4
source share
1 answer

The file url should be relative to your index.html (main html file). If your structure looks like this:

index.html
template
    template1.html
    template2.html

and in template 1 you want to add ng-include template2.html, you have to do

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

Here is a working example.

+7

Source: https://habr.com/ru/post/1543405/


All Articles