答案 0 :(得分:0)
Angular内置了验证输入的功能。您可以使用正则表达式来验证密码:
<div>
<input placeholder="Enter your password" [(ngModel)]="password" #pwField="ngModel" type="password" pattern="[a-zA-Z]*[0-9]+[a-zA-Z]*">
</div>
<div *ngIf="!pwField.valid">Your password should contain at least one digit.</div>
答案 1 :(得分:0)