0

Im using Angular 7 and Angular material matTooltip.

I want that the tooltip displays every element in the next line, something like this:

enter image description here

But, instead I'm getting this:

enter image description here

I got 3 elements per line, and I don't want that. I want one element/line.

My code is as follows:

app.component.ts

items=['15-09-2020: 200','16-09-2020: 200','17-09-2020: 200', '18-09-2020: 200'];
newItems = this.items.join("\r\n");

app.component.html

<div class="col col-sm-2" matTooltipPosition="after" matTooltip="{{ items}}"></div>

Check this example that is not working for me:

Stackbliz

Amos Isaila
  • 196
  • 11

1 Answers1

0

I have fixed this in my project using &#13;&#10;

So, what you'll need to do is:

newItems = this.items.join("&#13;&#10;");

Another thing, you need to change this:

matTooltip="{{ items}}"

To this:

[matTooltip]="items"
Asaf
  • 1,218
  • 7
  • 15