Search code examples
javascriptangularjsscopeattributes

how can call the scope function on ng-title attribute in angular.js


This is my html code

 <td ng-title="tileOfAbsent(this.attendance.absent)" ng-  
  style="IsAbsOrPres(this.attendance.absent)" style="color: red">  
  {{attendance.absent}}</td>

This is controller

 $scope.tileOfAbsent = function (value) {
            var title1= "Absent";
            var title2= "Present";
            if (value == "AA") {
                return title1;
            }
            else {
                return title2;
            }
        }

 $scope.IsAbsOrPres = function (value) {
        var style1 = { color: "#F41212" };
        var style2 = { color: "#178908" };
        if (value == "AA") {
            return style1;
        }
        else {
            return style2;
        }
    }

Problem is tileOfAbsent function does not executed(I have checked with using break point). But the IsAbsOrPres function is executed as expected .

Why ng-title does not call the function?


Solution

  • I got it by using title instead of ng-title

    like, title="{{tileOfAbsent(this.attendance.absent)}}"


    this is my full working code

    <td title="{{tileOfAbsent(this.attendance.absent)}}" ng-style="IsAbsOrPres
    (this.attendance.absent)" style="color: red">{{attendance.absent}}</td>