条件ng-include不在AngularJS中工作

时间:2014-05-15 07:23:48

标签: javascript angularjs

我正在开发AngularJS应用程序。我使用ng-include包含页眉和页脚页面,因为页眉和页脚对于所有页面都是相同的。但是我的左侧导航菜单页面不是第一个登录页面的一部分,但是所有其他页面都需要包含左侧导航页面。

所以我尝试在登录页面以外的所有页面中包含左侧导航页面。但不知怎的,它不起作用。

的index.html

<header>
      <div ng-include src="'html/templates/header.html' "></div>
 </header>
 <div ng-include src="'getPartial()'"></div>
 <div ng-view=""></div>
 <footer>
      <div ng-include src="'html/templates/footer.html'"></div>
 </footer>

我的控制器

angular.module('webApp').controller ('LoginController',function ($scope){
     $scope.getPartial = function () {
         return '';
     };
});


angular.module('webApp').controller ('editAccountController',function ($scope){
     $scope.getPartial = function () {
         return 'html/templates/leftNav.html';
     }; 
});

0 个答案:

没有答案