【发布时间】:2019-10-02 06:34:03
【问题描述】:
我有一个下拉列表,其中包含:父亲、母亲和监护人。后面是一个没有占位符的输入文本框。我希望文本框的占位符根据所选值动态更新
我尝试在 ts 文件部分中为占位符属性分配一个字符串。但它只能选择那个特定的值。我希望它选择 *ngIf
this is the select drop-down
<mat-select placeholder="Relation to Student"formControlName="relationType">
<mat-option *ngFor="let relation of relationType" [value]="relation">
{{ relation }}
</mat-option>
</mat-select>
this is the html input
<input matInput placeholder="{{related}} " formControlName="fatherFullName" required>
this is the ts and i know this isn't how it works. i'm sure of adding an "if" but i'm not sure of how to do it
related = ' Father's full name';
我期待的结果是,如果在选择下拉菜单中选择了父亲,则输入文本框中的占位符应该是父亲的全名。
提前致谢!
【问题讨论】:
-
如果你能创建一个stackblitz,那将会很有帮助。
标签: angular select placeholder