I'm trying to do simple think. use ng-include in loop for including multiple html pages to rendered page.
<div ng-controller="pageCTRL">
<div ng-repeat="mod in modules">
<div ng-include src='partials/{{mod}}.html'></div>
</div>
</div>
$scope.modules = ["mod_nav","mod_feature","mod_footer"];
But all i get is this.
Error: Syntax Error: Token 'mod' is unexpected, expecting [:] at column 12 of the expression [partials/{{mod}}.html] starting at [mod}}.html].
at Error (<anonymous>)
at throwError (angular.js:6066:11)
at consume (angular.js:6104:7)
at object (angular.js:6394:9)
at primary (angular.js:6278:17)
at unary (angular.js:6265:14)
at multiplicative (angular.js:6251:39)
at additive (angular.js:6239:16)
at relational (angular.js:6230:16)
at equality (angular.js:6221:16) <div ng-include="" src="partials/{{mod}}.html">
Do you have some solution how to do it?
rendered code looks like this:
<div ng-include="" src="partials/mod_nav.html"></div>
so I don't see what I'm doing wrong
ng-include
's src
expects an expression, not a string :
<div ng-include src="'partials/' + mod + '.html'"></div>
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