Jquery 如何使用Angularjs包含页眉和页脚?

Jquery 如何使用Angularjs包含页眉和页脚?,jquery,angularjs,Jquery,Angularjs,在我的项目中,我使用jquery“load”方法在所有页面中注入页眉和页脚(参考下面的代码),这里我的问题是如何使用angularjs实现同样的效果 $("header").load("includes/header.html"); $("footer").load("includes/footer.html"); $(“header”).load(“includes/header.html”); $(“footer”).load(“includes/footer.html”); 您应该使用指

在我的项目中,我使用jquery“load”方法在所有页面中注入页眉和页脚(参考下面的代码),这里我的问题是如何使用angularjs实现同样的效果

$("header").load("includes/header.html"); $("footer").load("includes/footer.html"); $(“header”).load(“includes/header.html”); $(“footer”).load(“includes/footer.html”); 您应该使用指令。它获取、编译并包含一个外部HTML片段

范例

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

在index.html或母版页中,您可以添加

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

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


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

//您可以在此处管理其他视图
更多参考资料