【发布时间】:2021-03-12 15:12:49
【问题描述】:
我使用扩展名@angular-material-extensions/password-strength 并且只是从这里复制了展示示例https://angular-material-extensions.github.io/password-strength/home
不知何故,原色永远不会出现。只出现蓝色和红色。我还必须添加一个
ngAfterViewChecked() {
this.cdRef.detectChanges();
}
修复颜色Expression has changed after it was checked...的错误
颜色确实会变成粉红色,当它 100% 选中时只是蓝色,但我当然希望它是绿色的。
我的组件.html:
<tr>
<td>
<mat-card-subtitle>
<mat-slide-toggle [(ngModel)]="showDetails" [ngModelOptions]="{standalone: true}">Show Password Requirements</mat-slide-toggle>
</mat-card-subtitle>
<mat-form-field appearance="outline" class="example-full-width" [color]="passwordComponent.color">
<mat-pass-toggle-visibility #toggle matSuffix></mat-pass-toggle-visibility>
<input matInput [type]="toggle.type" required placeholder="Password" #password formControlName="password"
type="password" />
<mat-hint align="end" aria-live="polite">
{{password.value.length}} / 25
</mat-hint>
<mat-error *ngIf="formErrors.password" class="form__error">{{ formErrors.password }} </mat-error>
</mat-form-field>
<mat-password-strength #passwordComponent min="4" [password]="password.value">
</mat-password-strength>
<mat-password-strength-info
*ngIf="showDetails"
[passwordComponent]="passwordComponent">
</mat-password-strength-info>
</td>
</tr>
<tr>
<tr>
<td>
<mat-form-field class="example-full-width">
<input matInput required placeholder="Password Confirmation" compare="password"
name="passwordConfirmation" formControlName="passwordConfirmation" type="password" />
<mat-error *ngIf="formErrors.passwordConfirmation" class="form__error">
{{ formErrors.passwordConfirmation }} </mat-error>
</mat-form-field>
</td>
</tr>
编辑:我还发现,如果我添加选项 floatLabel="always",<mat-form-field> 会忽略它,因为自动功能本身不适用于该字段。
【问题讨论】:
标签: angular