ng-include with a variable for src

前端 未结 2 1416
遥遥无期
遥遥无期 2021-01-01 10:17

I would like to change the ng-includes src with a variable. Currently this is what I have.

 
&l
相关标签:
2条回答
  • 2021-01-01 10:36

    Try as follows:

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

    -----------------OR----------------------

    You can do this way,

    View:

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

    Controller:

    function AppCtrl ($scope) {
      $scope.getPartial = function () {
          return 'partials/issues.html';
      }
    }
    
    0 讨论(0)
  • 2021-01-01 10:38

    Like this. You need to use single quotes and +, like you would in JavaScript.

    <ng-include src="'/path/to/template'+ my.variable +'.html'"></ng-include>
    
    0 讨论(0)
提交回复
热议问题