I'm using angular6 with angular material to create this neat website.
I'm using a mat-form-field
with mat-input
so show a text input element with a placeholder
text.
the placeholder text position has two states.
one! when the text input is empty and you are not focused into that element:
and the other when you focused on the input text and/or you the input text is not empty
I want the mat-input element to be in the 2nd state. to show the placeholder above the text input element even when there is no text in it and i'm not focused on that element.
I know i can make a work-around and add some sort of empty space to the value of the element.. but is there a more elegant way to achieve what I need?
thanks!!!
Dynamic placeholder binding in Angular component emailPlaceholderText is a variable of type string in the Angular component. With property binding, placeholder is defined inside square brackets and the syntax is as follows. <input id="email" class="form-control" [placeholder]="emailPlaceholderText">
You can use floatLabel="always"
, which is the input property binding for mat-form-field
<mat-form-field style="width: 100%" floatLabel="always">
<input matInput placeholder="Enter Name">
</mat-form-field>
Working Stackblitz
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With