AngularJS Tutorial - ng-attr-title adds tooltip to element








The following code shows how to use ng-attr-title to add tooltip to element.

Example


<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<script type='text/javascript'>
var app = angular.module('myApp', []);
function ctrl($scope){<!--  ww  w . j a v  a2  s  . c o m-->
    $scope.title = "I 'm a tooltip!";
}
</script>
</head>
<body>
  <div ng-app="myApp" ng-controller="ctrl">
    <div ng-attr-title="{{title}}">Hello Buddy!</div>
</div>
</body>
</html>

The code above is rendered as follows: