-->

What file path would I use with ng-include?

2019-03-24 16:16发布

问题:

My angular project's path is like this

web
    server.py ##flask server program
    app
        static
            app.js
            controllers.js
            etc...
        templates
            index.html
            home.html

index.html

<!-- this didn't work -->
<ng-include src="templates/home.html"><ng-include>

<!-- nor did this -->
<ng-include src="home.html"></ng-include>

home.html

<h1> home! </h1>

Except I don't see the partial (home.html) in my output.

Anyone see my mistake?

回答1:

The src attribute of ng-include expects a string. Either you pass a scope variable, or pass string directly.

<ng-include src=" 'templates/home.html' "></ng-include>