Angular:ng-include在页面加载时自动注释

时间:2015-06-02 07:29:19

标签: angularjs angular-ui-router

我使用ng-include分隔html页面,但是当我加载页面时,ng-include被自动注释,我不知道在ng-include上发生了什么。

代码:

<body>

    <div ng-include="templates/header.html"></div>

    <ul>
        <li><a ui-sref="home">home</a></li>
        <li><a ui-sref="about">about</a></li>
        <li><a ui-sref="contact">contact</a></li>
    </ul>

    <div ui-view></div>

    <div ng-include="templates/footer.html"></div>

</body>

加载后:

<body>

    <!--

     ngInclude: templates/header 

    -->
    <ul></ul>
    <!--

     uiView:  

    -->
    <div class="ng-scope" ui-view=""></div>
    <!--

     ngInclude: templates/footer 

    -->

</body>
是的,这让我感到困惑......

1 个答案:

答案 0 :(得分:0)

尝试像这样使用

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

<ul>
    <li><a ui-sref="home">home</a></li>
    <li><a ui-sref="about">about</a></li>
    <li><a ui-sref="contact">contact</a></li>
</ul>

<div ui-view></div>

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

  

data-ng-include =“'{filePath}'”(单引号)

如果不起作用,请尝试使用浏览器开发者工具跟踪请求