Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include header and footer using Angularjs?

In my projects i'm using jquery "load" method to inject the header and footer in all pages (ref the below code), here my question is how to achieve the same using angularjs.

$("header").load("includes/header.html");

$("footer").load("includes/footer.html");
like image 320
Abilash Avatar asked Feb 21 '14 11:02

Abilash


2 Answers

You should use ngInclude directive. It fetches, compiles and includes an external HTML fragment.

Example

<header ng-include="'includes/header.html'">                    
</header>
like image 194
Satpal Avatar answered Oct 13 '22 13:10

Satpal


In your index.html or master page you can add

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

<div ui-view=""></div>  // here you can manage other views 


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

For more references

http://docs.angularjs.org/tutorial/step_07

like image 20
Prashobh Avatar answered Oct 13 '22 11:10

Prashobh