【发布时间】:2019-11-01 06:17:43
【问题描述】:
我有两个字段。一个是 ID,另一个是 URL。我的问题是如何在字段中提供固定文本。 在下面的代码中,在 URL 字段中,用户必须提供 IP 地址和端口号。在该字段中,应该有固定文本 https:\。在此 之后应该输入用户的数据>https:\.在数据库中存储时,数据应该像https:\192.145.23.45\7894。
请回答这个问题。
提前致谢:)
<mat-form-field appearance="outline">
<mat-label>url</mat-label>
<input matInput placeholder="Url"formControlName="url" >
<mat-error *ngIf="appawareform.controls.url.invalid &&
appawareform.controls.url.touched &&
!appawareform.controls.url.value">url is required</mat-error>
<mat-hint align="start">NOTE:server:portno</mat-hint>
</mat-form-field>
【问题讨论】:
-
到目前为止你尝试了什么?
-
这能回答你的问题吗? How to add static text inside an input form
-
可以在mat-form-field中添加
<span matPrefix>https://</span>来显示。要存储它,只需在发送到服务器之前修补值 -
我正在使用外观outline。所以它重叠了。还有其他方法吗?
标签: angular