I have a tooltip working on a glyphicon. When I click on the glyphicon I want to hide the tooltip, and then change the text of the tooltip. This reflects a change in state for the glyphicon which has been clicked.
我有一个雕文工具提示。当我点击图标时,我想要隐藏工具提示,然后更改工具提示的文本。这反映了已单击的符号图标的状态变化。
However, when I hide the tooltip and then change the text of the tooltip, instead of doing it in this order, for a second you can see the new text in the tooltip before it disappears.
但是,当我隐藏了工具提示,然后更改了工具提示的文本,而不是按照这个顺序,您可以在工具提示中看到新的文本,然后在它消失之前。
Here is the html:
html:
<span class="glyphicon glyphicon-eye-open watch-eye"
ng-click="eyeClicked()" uib-tooltip="{{watchTooltip}}"
tooltip-placement="auto top" tooltip-is-open="eyeTooltipIsOpen">
</span>
And here is javascript:
这里是javascript:
$scope.watchingCategory = false;
$scope.watchTooltip = 'Watch';
$scope.eyeClicked = function() {
$scope.eyeTooltipIsOpen = !$scope.eyeTooltipIsOpen;
$scope.watchingCategory = !$scope.watchingCategory;
if($scope.watchingCategory === true) {
$scope.watchTooltip = 'Dont watch';
}
else if($scope.watchingCategory === false) {
$scope.watchTooltip = 'Watch';
}
};
I've created a plnkr to show exactly how it is working: http://plnkr.co/edit/myQlkkiSNO14td21Dv0M
我创建了一个plnkr来展示它是如何工作的:http://plnkr.co/edit/myQlkkiSNO14td21Dv0M
Any ideas how to stop this behaviour? All help appreciated...
有什么办法阻止这种行为吗?所有的帮助感激……
1 个解决方案
#1
2
This is probably a problem whitin the uib directive.
这可能是uib指令中的一个问题。
A timeout solves the problem :
超时解决了这个问题:
$timeout(function(){
$scope.watchTooltip = $scope.watchingCategory ? 'Dont watch' : 'Watch';
}, 200);
http://plnkr.co/edit/myQlkkiSNO14td21Dv0M?p=preview
http://plnkr.co/edit/myQlkkiSNO14td21Dv0M?p=preview
#1
2
This is probably a problem whitin the uib directive.
这可能是uib指令中的一个问题。
A timeout solves the problem :
超时解决了这个问题:
$timeout(function(){
$scope.watchTooltip = $scope.watchingCategory ? 'Dont watch' : 'Watch';
}, 200);
http://plnkr.co/edit/myQlkkiSNO14td21Dv0M?p=preview
http://plnkr.co/edit/myQlkkiSNO14td21Dv0M?p=preview