refactor vnTooltip

This commit is contained in:
Daniel Herrero 2018-02-21 13:42:47 +01:00
parent 027c19f5c5
commit b5611d0cc5
1 changed files with 7 additions and 5 deletions

View File

@ -34,11 +34,12 @@ function tooltip($document, $compile, $interpolate, $sce, $templateCache, $http,
return {
restrict: 'A',
priority: -1,
link: function(scope, element, attrs) {
var tipHtml = '<div class="mdl-shadow--2dp" ng-class="tipClass"><div class="tooltip-text" translate>{{text}}</div><div ng-if="isHtmlContent" ng-bind-html="htmlContent"></div><div class="tooltip-arrow"></div></div>';
var tip;
var tipClassName = 'tooltip';
var tipActiveClassName = 'tooltip-show';
link: function($scope, element, attrs) {
let tipHtml = '<div class="mdl-shadow--2dp" ng-class="tipClass"><div class="tooltip-text" translate>{{::text}}</div><div ng-if="isHtmlContent" ng-bind-html="htmlContent"></div><div class="tooltip-arrow"></div></div>';
let tip;
let tipClassName = 'tooltip';
let tipActiveClassName = 'tooltip-show';
let scope = $scope.$new();
scope.tipClass = [tipClassName];
scope.text = attrs.vnTooltip || '';
@ -116,6 +117,7 @@ function tooltip($document, $compile, $interpolate, $sce, $templateCache, $http,
element.on('$destroy', function() {
tip.remove();
scope.$destroy();
});
}
}