小编典典

ng-include和src变量

angularjs

我想用变量更改ng-includes src。目前这就是我所拥有的。

 <div class='alignRightCenter' id='rightContent'>
    <ng-include src="'{{view}}'"> </ng-include>
</div>

这是控制器:

ctrl.controller('contentCtrl', ['$scope', function($scope) {
      $scope.view = "partials/setListName.tpl.html";
  }]);

不幸的是,我无法使用ng-view,因为它已经被用来引导我进入此页面。是否可以进行类似的工作?


阅读 469

收藏
2020-07-04

共1个答案

小编典典

尝试如下:

<ng-include src="view"> </ng-include>

- - - - - - - - -要么 - - - - - - - - - - -

你可以这样

视图:

<div data-ng-include data-ng-src="getPartial()"></div>

控制器:

function AppCtrl ($scope) {
  $scope.getPartial = function () {
      return 'partials/issues.html';
  }
}
2020-07-04