1

I am working in an angular 5 application ,Here I am using Angular Material Design for UI .

Now I want to design a input filed as like in the image

enter image description here

I don't know how to add the "Change" label inside he input field .

Stackblitz : https://stackblitz.com/edit/angular-stacb4-5oaagd?file=app%2Fsnack-bar-overview-example.html

app.component.html

<mat-form-field class="col-sm-12">
    <mat-label>Enter your email</mat-label>
    <input matInput placeholder="email" required>
</mat-form-field>

Can anyone help me to solve this .

3 Answers 3

2

you can use like this,

<mat-form-field class="col-sm-12">
    <mat-label>Enter your email</mat-label>
    <input #inp matInput placeholder="email" required>
   <span matSuffix class="lbl" (click)="inp.value = ''">change</span>
</mat-form-field>

and in style.css

.lbl {
   color: #1787dc;
   cursor: pointer;
}

Stackblitz demo

Sign up to request clarification or add additional context in comments.

Comments

2

use matSuffix for this

<mat-form-field class="col-sm-12">
    <mat-label>Enter your email</mat-label>
    <input matInput placeholder="email" required>
  <button matSuffix (click)="getData()">Change</button>
</mat-form-field>

Comments

1

try This if you need something like this

enter image description here

<mat-form-field class="col-sm-12">
    <mat-label matSuffix >Enter your email</mat-label>
  <a matSuffix > change ? </a>
    <input matInput placeholder="email" required>
</mat-form-field>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.