Angular 2工具提示仅在使用css类时

时间:2018-02-08 09:22:58

标签: css angular

我有一个标签太长的按钮,所以我创建了一个省略号的类:

<button type="submit" title="{{'button.label' | translate}}"
 (click)="doSomething()">
    <span class="labelEllipsis">{{'button.label' | translate}}</span>
</button>

其中labelEllipsis类是:

.labelEllipsis{
    text-overflow: ellipsis!important;
    -ms-text-overflow: ellipsis !important;
    overflow: hidden;
    white-space: nowrap; 
    display: block;
}

问题是,即使标签没有用省略号截断,也始终显示工具提示。我的问题是:只有在标签实际被截断时才有显示工具提示的方法吗? 感谢

1 个答案:

答案 0 :(得分:0)

标题属性默认显示工具提示。您可以创建基于指令或条件的属性,例如,如果您的char限制超过(您的限制),然后显示属性或类似的属性。

ng-attr-title="{{this[message]}}"

这将帮助您放置基于条件的标题..