Javascript 如何在angularjs中悬停显示文本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28924756/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 02:37:17  来源:igfitidea点击:

How to display text in hover over in angularjs?

javascriptjquerycssangularjs

提问by butYouDontLookLikeADeveloper

I am very new to AngularJS. I want to display {{Project.inrtcvalue}}when the mouse is hovered over values. How can I do this in AngularJS?

我对 AngularJS 很陌生。我想{{Project.inrtcvalue}}在鼠标悬停在值上时显示。我怎样才能在 AngularJS 中做到这一点?

<table ng-table="tableParams" show-filter="true" class="table" >
    <tr  ng-class="{'danger': project.rag <= 35, 'warning': project.rag > 35 && project.rag < 70  , 'success': project.rag > 70}" ng-repeat="project in $data">
        <td data-title="'PRN'" sortable="'prn'" filter="{'prn': 'text'}">
            {{project.prn}}
        </td>
    </tr>
</table>

So when the user hovers over these <td>I want to display a value from a controller. How do I do this? What is the best way to do this?

因此,当用户将鼠标悬停在这些上方时,<td>我想显示来自控制器的值。我该怎么做呢?做这个的最好方式是什么?

回答by Dylan Watson

You should simply be able to use the {{variable}}notation within a HTML title tag.

您应该能够{{variable}}在 HTML 标题标签中使用该符号。

So something like:

所以像:

<td title="{{project.inrtcvalue}}">

See this plunkrfor an example (Thanks dfsq)

请参阅此plunkr以获取示例(感谢dfsq

回答by Kamran

You can use ng-mouseoverand ng-showdirectives to accomplish this.Following is the example. Example.Hope it helps to get you started.

您可以使用ng-mouseoverng-show指令来完成此操作。以下是示例。示例。希望它可以帮助您入门。