角:提示怎么触发的作品? [英] Angular: how tooltip-trigger works?

查看:127
本文介绍了角:提示怎么触发的作品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,应该在KEYUP显示,当它的值是无效的工具提示。我不知道为什么。

I have a tooltip that should be shown on keyup when value of it is invalid. I don't know why

<input name="myInput" tooltip-trigger="{{{true: 'keyup', false: 'blur'}[true]}}" ...

始终显示了我一个提示,

always shows me a tooltip,

<input name="myInput" tooltip-trigger="{{{true: 'keyup', false: 'blur'}[false]}}" ...

从来没有显示我吧,
为什么

never shows me it, and why

<input name="myInput" tooltip-trigger="{{{true: 'keyup', false: 'blur'}[myForm.myInput.$invalid]}}" ...

也始终显示了我一个提示,即使 $无效正在发生变化。

还有什么比这第三个例子的原因是什么?如何使它表现为我们可以期待?

What could be the reason of third example? How to make it behave as we can expect?

推荐答案

这是因为你被绑定一次只需要更新 {{{真:KEYUP',假:模糊 } [myForm.myInput。$无效]}} 输入字段的值更改。您可以使用 NG-变化函数,该函数和放大器;然后更新变化的提示触发值。

That is because you are binding it once only you need to update {{{true: 'keyup', false: 'blur'}[myForm.myInput.$invalid]}} value on change of input field. You can use ng-change function for that & then update the tooltip trigger value on change.

标记

<input name="myInput" ng-change="updateTooltip()"
tooltip-trigger="{{tooltipTriggerType}}" .../>

code

$scope.updateTooltip = function(){
    $scope.tooltipTriggerType = {true: 'keyup', false: 'blur'}[$scope.myForm.myInput.$invalid]
    return $scope.tooltipTriggerType;
};

这篇关于角:提示怎么触发的作品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆