I would like to change the ng-includes src with a variable. Currently this is what I have.
<div class='alignRightCenter' id='rightContent'> <ng-include src="'{{view}}'"> </ng-include> </div>
And here is the controller:
ctrl.controller('contentCtrl', ['$scope', function($scope) { $scope.view = "partials/setListName.tpl.html"; }]);
Unfortunately I can not use a ng-view because it is already being used to get me to this page. Is it possible to make something like this work?
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'; } }
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With