Aus*_*ell 27 javascript angularjs angularjs-ng-include
我想用变量更改ng-includes src.目前这就是我所拥有的.
<div class='alignRightCenter' id='rightContent'>
<ng-include src="'{{view}}'"> </ng-include>
</div>
Run Code Online (Sandbox Code Playgroud)
这是控制器:
ctrl.controller('contentCtrl', ['$scope', function($scope) {
$scope.view = "partials/setListName.tpl.html";
}]);
Run Code Online (Sandbox Code Playgroud)
不幸的是我不能使用ng-view,因为它已被用于访问此页面.有可能做出像这样的工作吗?
Jat*_*til 52
尝试如下:
<ng-include src="view"> </ng-include>
Run Code Online (Sandbox Code Playgroud)
- - - - - - - - -要么 - - - - - - - - - - -
你可以这样做,
视图:
<div data-ng-include data-ng-src="getPartial()"></div>
Run Code Online (Sandbox Code Playgroud)
控制器:
function AppCtrl ($scope) {
$scope.getPartial = function () {
return 'partials/issues.html';
}
}
Run Code Online (Sandbox Code Playgroud)
JRT*_*JRT 11
像这样.您需要使用单引号和+,就像在JavaScript中一样.
<ng-include src="'/path/to/template'+ my.variable +'.html'"></ng-include>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
28256 次 |
| 最近记录: |