I try to create the following directive
function sortingTableHeader($compile) {
return {
link: function(scope, element, attrs) {
var tableHeaderEles = angular.element(element[0].querySelectorAll('th'));
angular.forEach(tableHeaderEles, function(tableHeaderEle) {
var thElement = angular.element(tableHeaderEle);
var thValue = thElement.text();
var sortIcon = '<span class="fa" ng-init="abc=' + theValue + '" ng-class="{\'fa-sort\': sortType != abc}">{{abc}}</span>';
thElement.append($compile(sortIcon)(scope));
});
}
};
}
I tried to call theValue variable in the element, it throws an error:
angular.js:14525 ReferenceError: theValue is not defined
Does anyone know how to call local variable in element?
Thanks a lot!