如何在密码表单字段中添加条件,该条件必须至少为 4 个字符,否则会出错

How do I add a condition to the password form field that must be at least 4 characters otherwise an error

输入您的密码
        <input matInput id="signup-credentials-password" type="text" style="color: #999999; font-size: 16px;" 
        #passwordSignup minlength="5" [type]="hide ? 'password' : 'text'">

在你的ts文件中,你可以设置password如下:

...
'password': new FormControl(null, [Validators.required, Validators.minLength(4)])
...

您可以在此页面上找到示例 ===> https://stackblitz.com/edit/angular-reactive-forms-bn9ecb