我想解决这个问题:Angular 5 - 模板驱动的形式
输入字段具有类型电子邮件.例:
<input type="email" [(ngModel)]="model.email" #email="ngModel" email />
Run Code Online (Sandbox Code Playgroud)
我想验证这个字段.但它不应该是必填字段.如果验证不为空,则应仅启动验证.如果该字段为空,则可以使用.否则,在电子邮件地址正确之前,应显示错误消息.
这不是真正的工作:
*ngIf="email.untouched && email.invalid"
Run Code Online (Sandbox Code Playgroud)
那么,我该如何验证电子邮件字段?我想念"不空"这样的状态.
任何提示?
我有一个带有德语日期的字符串(31.01.2019,DD.MM.YYYY)。现在我需要使用 date-fns 检查日期是否有效。
dateFns.isValid(new Date('19.11.2019'), 'DD.MM.YYYY');
Run Code Online (Sandbox Code Playgroud)
这是行不通的。我总是从 date-fns 得到错误的反馈。我认为 date-fns 期待另一种日期格式。
如何使用德语日期格式验证字符串?
i have problems with reactive forms and an array of radio buttons.
My Form looks like this:
There is a player in a row and i have to choose the status.
component:
<tr *ngFor="let data of player">
<th>{{data.firstname}} {{data.lastname}}</th>
<th *ngFor="let stat of status">
<input type="radio" id="opt1+{{data.id}}" value="{{stat}}" name="option+{{data.id}}" formArrayName="status???"></th>
</tr>
Run Code Online (Sandbox Code Playgroud)
The player data comes from an API and status is an array.
ts:
this.myForm = formBuilder.group({
status: this.formBuilder.array,
})
Run Code Online (Sandbox Code Playgroud)
My example does not work. I need a json-file as …