How can I get a dynamic title in angularJS.I know to use ng-attr-title as below
<div ng-app="myApp" ng-controller="ctrl"> <div ng-attr-title="{{title}}">Hover me</div> </div>
and controller
var app = angular.module('myApp', []); function ctrl($scope){ $scope.title = "I 'ma tooltip!"; }
Here is JSfiddle and its work. What I'm trying to do is to have two different headers, one at power-up and the other off, so I want to solve a variable that goes into ng-attr-title at runtime, as follows.
<div ng-app="myApp" ng-controller="ctrl"> <div ng-attr-title="{{message}}">Hover me</div> </div>
and controller
var app = angular.module('myApp', []); function ctrl($scope){ $scope.Enabledtitle = "U can click me"; $scope.Disabledtitle = "U cannot click me"; $scope.message="Enabledtitle"; }
So, when I am, I should get a tooltip "U can click me". SO that I get the flexibility to switch between tooltip messages by simply updating the message scope variable
Here is a JSfiddle where I tried the dynamic name and get "Enabledtitle" as a hint instead of "U can click on me."
How can I tell angular to parse {{Enabledtitle}} and evaluate its value.
source share