I am getting a below error when i try to do the below:
Controller:
function MyCtrl($scope) {
angular.forEach(document.querySelectorAll(".q"), function(val, key) {
(function(key, val) {
console.log(val.getAttribute("ng-class").replace(/\{{([ind]+)\}}/g, key));
})(key, val);
});
}
.ng-invalid {
border: 1px solid red;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="">
<div ng-controller="MyCtrl">
<div ng-class="{x:{{ind}}<id,y:{{ind}} >id, z :{{ind}} == id}" class="q"></div>
<div ng-class="{x:{{ind}}<id,y:{{ind}} >id, z :{{ind}} == id}" class="q"></div>
</div>
</div>
The above code prints fine in console replacing {{ind}} values perfectly, but when the application executes i get the below error:
Syntax Error: Token '<' not a primary expression at column 7 of the expression [{x:id,] starting at [{4}].
ng-classexpression while the application is running?indis dynamic, you don't need{{}}curly braces. Just use the variable as is. It's highly unlikely that anything you want to achieve requires this weird pattern.