1
I’m using Angular 8, example of mask would be landline and mobile phone.
That is to count the number of characters and apply such mask.
I am creating the mask with Ngx-Mask, trying with *ngIf in html, only it does not take the *ngIf condition, does not return error, only enters the Else "(00) 0 0000-0000".
<div class="form-group col-md-2">
<label for="telefone">Telefone</label>
<ng-container *ngIf="cliente.telefone && cliente.telefone?.length <= 10; else elseTemplate">
<input type="text" name="telefone" id="telefone" class="form-control" formControlName='telefone'
mask="(00) 0000-0000">
</ng-container>
<ng-template #elseTemplate>
<input type="text" name="telefone" id="telefone" class="form-control" formControlName='telefone'
mask="(00) 0 0000-0000">
</ng-template>
</div>
If you are not error is because your ngIf condition is being evaluated as "false". changes to *ngIf="customer.phone; Else elseTemplate" or *ngIf="customer.phone?. length <= 10; Else elseTemplate" or *ngIf="1>0; Else elseTemplate" to find out which condition is returning false
– brenodiogo
*ngIf="customer.phone false *ngIf="phone client?. length <= 10 true The two together never feels right. Any other hint?
– Pablo Ferreira
does not work for material angular 9, it worked something else.
– Paulo Dantas