Ng-include不起作用

时间:2013-05-20 09:09:34

标签: javascript templates angularjs

我有简单的angular.js申请。我还有index.html作为我的网络应用程序的首页,现在我想创建footer.html并将ng-include指令包含在我的index.html中。

我有根控制器:

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>

谢谢。

1 个答案:

答案 0 :(得分:0)

使用

ng-include="getFooter().url"

return $scope.templates[0].url;