I create simple example: plnkr. Try to enter something like 123qwe in first field. "qwe" doesn't disappear. But if enter a new digit all non-digit characters will disappear.
In second field non-digit characters is replacing by '!' and it field works as expected.
My code:
@Component({
selector: 'my-app',
providers: [],
template: `
<div>
Doesn't work: <input [value]="val | replace:pattern:''" (input)="val=$event.target.value">
<br>
Works: <input [value]="val2 | replace:pattern:'!'" (input)="val2=$event.target.value">
</div>
`,
directives: []
})
export class App {
val: string = "";
val2: string = "";
pattern = /[^0-9]/g;
constructor() {
}
}
Is there any workaround to make first field work like a second but with replacing with empty string? Is there expected behavior?
