Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax Error: Token 'mod' is unexpected, expecting [:] at column 12 of the expression [partials/{{mod}}.html] starting at [mod}}.html]

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

like image 762
zajca Avatar asked Jul 08 '13 18:07

zajca


1 Answers

ng-include's src expects an expression, not a string :

<div ng-include src="'partials/' + mod + '.html'"></div>
like image 196
Ven Avatar answered Sep 28 '22 04:09

Ven