I use angular 10 with angular material to build my website.
I want to add input suggestions to matInput
but in a different way that matAutocomplete
does..
i don't want to show a list, I want to show one suggestion to a word that the user is already typing inside the input as gray letters after the last character that is typed and if presses tab it will autocomplete the word.
example..
lets say I want to write the word beverage and I started typing only 'beve'
so the input will show beve|rage
the |
character is the position of the cursor, and it will show rage in gray and the user can't really move forward cause it's not really part of the input, but if he clicks type it actually added the missing laters to the word and moves the cursor after the position of the full word.
I don't even know how to to start searching for how to implement such a thing, because whenever i search the terms autocomplete
or suggestion
it all goes show tutorials on autocomplete list which is not what I want.
I tried to play with matInput
and mat-form-field
a bit and like a good solution would be if I could show the placeholder even after the user typed something cause it looks like it has the same effect more or less of what I need.
so if I create this:
<mat-form-field>
<mat-label>hello</mat-label>
<mat-hint>test</mat-hint>
<input matInput placeholder="foooooooo"/>
</mat-form-field>
so when I focus on the input element, i see foooooooo
in gray but when I start typing the placeholder is gone. if the placeholder could still be shown then I could manipulate the placeholder dynamically, I could change on keypress
even when the user clicks tab in order to complete the actual word in the input and move the cursor forward.
still don't know how to leave the placeholder! so if anyone got any idea how to do that.. or any other method to support what I need it would be great. thanks