With Html I don’t know if this is possible, but, nothing prevents you create as in the example below that is with Javascript
:
let input = document.getElementById('entrada');
let span = document.getElementsByTagName('span')[0];
span.style.display = 'none';
input.addEventListener('mouseover', () => {
if(input.value.length > 10) {
span.style.display = 'block';
span.innerHTML = input.value;
}
});
input.addEventListener('mouseout', () => {
span.style.display = 'none';
});
span {
color: #535250;
background-color: #faba6b;
padding: 3px;
margin-top: 5px;
}
<input type="text" id="entrada">
<span></span>
Passing the code to the Angular
would be like this with a simple example:
HTML
<input type="text" (mouseover)="showValue()" (mouseout)="hideValue()" #entrada>
<span [hidden]="visible" >{{ entrada.value }}</span>
TS
@ViewChild("entrada", { static: false }) entrada: ElementRef;
public visible = true;
ngOnInit() {}
showValue() {
if (this.entrada.nativeElement.value.length > 10) this.visible = false;
}
hideValue() {
this.visible = true;
}
Dude, your solution seems like it’s pretty close to helping me, but I still can’t make it work. I have an Angular application even, where the user needs to fill a mat-select --> mat-option. This implementation did not work with mat-option.. But I’ll keep trying. Thanks for the help!
– Vitor Rodrigues