如何在Angular 5中自定义Angular材质设计输入字段

问题描述 投票:0回答:3

我正在使用角度5应用程序,在这里我使用Angular Material Design for UI。

现在我想设计一个像图像一样的输入文件

enter image description here

我不知道如何在输入字段中添加“更改”标签。

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>

任何人都可以帮我解决这个问题。

angular typescript angular-material
3个回答
1
投票

你可以这样使用,

<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>

style.css

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

Z zxswい但是


2
投票

为此使用Stackblitz

matSuffix

1
投票

试试这个,如果你需要这样的话

<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>

enter image description here
© www.soinside.com 2019 - 2024. All rights reserved.