为什么ng-include不工作?

时间:2016-01-22 06:43:39

标签: javascript html angularjs

ng-include not working

目录结构如下:

ssh_project
--public
----templates
------header.html
------footer.html
----views
------index.html

现在这是我的index.html文件

<body>
    <h1>Hello</h1>
    <div ng-include='"../templates/header.html"'></div>
    <div ng-view></div>
    <div ng-include='"../templates/footer.html"'></div>
</body>

3 个答案:

答案 0 :(得分:2)

你必须首先使用双引号然后单引号。尝试以下

<body>
    <h1>Hello</h1>
    <div ng-include="'../templates/header.html'"></div>
    <div ng-view></div>
    <div ng-include="'../templates/footer.html'"></div>
</body>

答案 1 :(得分:0)

只是轻微的错误。

<body>
    <h1>Hello</h1>
    <div ng-include="'../templates/header.html'"></div>
    <div ng-view></div>
    <div ng-include="'../templates/footer.html'"></div>
</body>

答案 2 :(得分:0)

尝试<div ng-include="'../templates/header.html'"></div>,因为双引号应该在外面,单引号应该在里面。请更改并继续。