我有简单的 angular.js
应用。我还有index.html
作为我的网络应用程序的首页,现在我想创建 footer.html
并将其包含在 ng-include
中指令我的index.html
.
我有根 Controller :
function RootController ($scope) {
$scope.templates = [{name : 'footer.html', url : 'views/footer.html'}];
$scope.getFooter = function(){
return $scope.templates[0];
}
}
还有我的index.html
模板:
<div ng-controller="RootController" ng-include="getFoooter()">
....
</div>
footer.html
有一个简单的html:<div>Test Test Test</div>
但是当我打开index.html
时我没有看到页脚。为什么?如何正确包含它?
UPD
问题已解决。也许有人对我的解决方案有用:
它适用于:
<div ng-controller="SkinController" data-ng-include data-src="getFooter()">
</div>
谢谢。
最佳答案
使用其中之一
ng-include="getFooter().url"
或
return $scope.templates[0].url;
关于javascript - NG-include 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16646090/