简体   繁体   English

Angular 2-如何在角度垫上给出复制选项

[英]Angular 2 - how to give copy option on angular matTooltip

I am using matTooltip to show tooltip in Angular. 我正在使用matTooltip在Angular中显示工具提示。 I am facing two issues - 我面临两个问题-

1) I want to give copy option on matTooltip to copy tooltip text. 1)我想给在matTooltip复制选项复制工具提示文本。 How to give it. 怎么给。

2) My second issues is since my tooltip text is large or long it is not getting shown completely on the tooltip it is wrapped with three dots at end(eg "Thisistooltip..."). 2)我的第二个问题是,由于我的工具提示文本很大或很长,因此工具提示上没有完全显示它,它的末尾用三个点包裹(例如“ Thisistooltip ...”)。

Please guide if anyone faced this same issue. 请指导是否有人遇到同样的问题。

1- Copy Text 1-复制文字

You can use ngxClipboard for copying... 您可以使用ngxClipboard复制...

<a 
   ngxClipboard
   (click)="copyToClipboard()"
   [cbContent]="textYouNeedToCopy" />
</a>

Also you need to add FormsModule && ClipboardModule in your app.module.ts: 另外,您还需要在app.module.ts中添加FormsModule && ClipboardModule

import { FormsModule } from '../../node_modules/@angular/forms';
import { ClipboardModule } from 'ngx-clipboard';

Add it to the imports too... 也将其添加到导入中...

2- Show full text 2-显示全文

I didn't faced this issue but I found a git issue may be this is useful: https://github.com/angular/material2/issues/3531 我没有遇到这个问题,但是我发现一个git问题可能有用: https : //github.com/angular/material2/issues/3531

It explicitly give css to the tool-tip and here's the css 它显式地将CSS提供给工具提示,这是CSS

.mat-tooltip {
    max-width: 50px;
    /* or */
    /* width: 50px; */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM