我在 angular2 中使用模板驱动形式。开发的表单在桌面和安卓系统中运行良好,但是当我在 iphone 的 chrome 中自动填写表单时,表单无效。我也怀疑在表单标签中使用 novalidate 是否将自动完成设置为关闭?下面是我的代码。
<form #form="ngForm" (ngSubmit)="form.valid && onSubmit(form)" novalidate>
<input id="firstName" #firstName="ngModel" [(ngModel)]="firstName" type="text" name="firstName"
placeholder="*First Name" pattern="[a-zA-Z][a-zA-Z0-9\s]*"
[class.has-error]="firstName.invalid && form._submitted" maxlength="40" autocomplete="on" required>
<input id="lastName" #lastName="ngModel" [(ngModel)]="lastName" type="text" name="lastName"
placeholder="*Last Name" pattern="[a-zA-Z][a-zA-Z0-9\s]*"
[class.has-error]="lastName.invalid && form._submitted" maxlength="80" autocomplete="on" required><br>
<input id="email" type="email" #email="ngModel" name="email" [(ngModel)]="localLeader.email"
pattern="[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$" placeholder="*Email"
[class.has-error]="email.invalid && form._submitted" maxlength="80" autocomplete="on" required><br>
<input type="checkbox" name="isLocal" [(ngModel)]="isLocal">
<div class="indicator"></div>
<span id="monthly"> Local</span>
<button class="sc-btn" type="submit">GET DATA</button>
</form>
有什么帮助吗?