Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What file path would I use with ng-include?

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?

like image 950
Zack Avatar asked Aug 26 '14 06:08

Zack


People also ask

What is required with Ng-include directive?

The ng-include directive includes HTML from an external file. The included content will be included as childnodes of the specified element. The value of the ng-include attribute can also be an expression, returning a filename. By default, the included file must be located on the same domain as the document.

Why we use NG-include in AngularJS?

The primary purpose of the ng-include directive is used to fetch, compile, and include an external HTML file in the main AngularJS application. These are added as child nodes in the main application. The ng-include attribute's value can also be an expression, that returns a filename.

Does Ng-include create a new scope?

ngInclude creates a new child scope which inherits scope values from the parent controller.

For what purpose file paths are used?

A file path describes the location of a file in a web site's folder structure. File paths are used when linking to external files, like: Web pages. Images.


1 Answers

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>
like image 154
Raghavendra Avatar answered Sep 29 '22 17:09

Raghavendra