In your directive, you can use the service $ compile
And also set the priority properties to a high value, so that the directive is processed first, and the terminal property to true , so that after processing this directive, others are not processed.
In the link function, you need to remove the attribute corresponding to the directive, add the necessary attributes with values, and use $compile .
based on the answer Add directives from directive in AngularJS
Example:
angular.module('ui.bootstrap.demo', ['ngAnimate', 'ui.bootstrap']); angular.module('ui.bootstrap.demo').controller('TooltipDemoCtrl', function($scope, $sce) { $scope.employee = { name: "Employee", age: "20", xyz: "XYZ" } }).directive('my1', function($compile) { return { priority: 1001, terminal: true, link: function link(scope, el, attrs) { var linkFn = $compile( el.removeAttr('my1') .attr('tooltip-placement', 'right') .attr('uib-tooltip', '{{employee.name + employee.age + employee.xyz}}') ); linkFn(scope); } }; });
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.js"></script> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-animate.js"></script> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-sanitize.js"></script> <script src="//angular-ui.imtqy.com/bootstrap/ui-bootstrap-tpls-2.1.4.js"></script> <link href="//netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"> <div ng-app="ui.bootstrap.demo" ng-controller="TooltipDemoCtrl"> <span my1 ng-bind="employee.name"> </span> </div>