0

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!

31piy
  • 23,323
  • 6
  • 47
  • 67
Becky.Z
  • 1
  • 3

1 Answers1

1

Is it theValue or thValue! You have defined thValue, not theValue.

31piy
  • 23,323
  • 6
  • 47
  • 67
Srinivas ML
  • 732
  • 3
  • 12