My question is that, how can I add a pipe like that to a reactive form, for non-reactive cases, I have seen that it can be done in the following way.
<input [ngModel]="item.value | useMyPipeToFormatThatValue"
(ngModelChange)="item.value=$event" name="inputField" type="text" />
Now I am using the angular form reagents2, and that doubt arose, this is my html code.
<form [formGroup]='fb'>
<input type="text" [formControl]='searchTerm'>
<button (click)="formClick()">FormClick</button>
<input type="text" [formControl]="masterValue">
</form>
<ul>
<li *ngFor="let user of users">
{{user.name}}
</li>
</ul>
<p>{{master | masterPipe}}</p>
my MasterPipe.ts
export class MasterPipe implements PipeTransform{
transform(master:string){
const market=4;
let oculto=master.slice(0,-market);
let visible=master.slice(-market);
let a:string=oculto.replace(/./g,'*')+visible;
return a;
}
}
I want to add that pipe to the input with the formControl = masterValue, something like this in the line below but in the same input.
<p>{{master | masterPipe}}</p>