refactor vnTooltip
This commit is contained in:
parent
027c19f5c5
commit
b5611d0cc5
|
@ -34,11 +34,12 @@ function tooltip($document, $compile, $interpolate, $sce, $templateCache, $http,
|
||||||
return {
|
return {
|
||||||
restrict: 'A',
|
restrict: 'A',
|
||||||
priority: -1,
|
priority: -1,
|
||||||
link: function(scope, element, attrs) {
|
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>';
|
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>';
|
||||||
var tip;
|
let tip;
|
||||||
var tipClassName = 'tooltip';
|
let tipClassName = 'tooltip';
|
||||||
var tipActiveClassName = 'tooltip-show';
|
let tipActiveClassName = 'tooltip-show';
|
||||||
|
let scope = $scope.$new();
|
||||||
|
|
||||||
scope.tipClass = [tipClassName];
|
scope.tipClass = [tipClassName];
|
||||||
scope.text = attrs.vnTooltip || '';
|
scope.text = attrs.vnTooltip || '';
|
||||||
|
@ -116,6 +117,7 @@ function tooltip($document, $compile, $interpolate, $sce, $templateCache, $http,
|
||||||
|
|
||||||
element.on('$destroy', function() {
|
element.on('$destroy', function() {
|
||||||
tip.remove();
|
tip.remove();
|
||||||
|
scope.$destroy();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue