最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - AngularJs: ng-include not working when placed inside a ng-view tag - Stack Overflow

programmeradmin1浏览0评论

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

I tried all the below syntax =

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

None working. But If I put the same tag outside the ng-view its working fine.

What am I doing wrong?

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

I tried all the below syntax =

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

None working. But If I put the same tag outside the ng-view its working fine.

What am I doing wrong?

Share Improve this question edited Jun 5, 2014 at 12:07 user221755 asked Jun 5, 2014 at 12:04 user221755user221755 411 silver badge4 bronze badges 1
  • Does the ngInclude get placed by default in the template or are you putting it there with JavaScript? – Mike Quinlan Commented Jun 5, 2014 at 16:31
Add a ment  | 

1 Answer 1

Reset to default 6

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

index.html
template
    template1.html
    template2.html

and in template1 you want to ng-include template2.html, you should do

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

Here is a working example.

发布评论

评论列表(0)

  1. 暂无评论