i need to add an hyphen after every 4 digit i enter, i am getting this in the console , how can i can achieve this to change in the input in angular 2
Code i used given below .ts
mychange(val){
var self = this;
var chIbn = self.storeData.iban_no.split("-").join("");
if (chIbn.length > 0) {
chIbn = chIbn.match(new RegExp('.{1,4}', 'g')).join("-");
}
console.log(chIbn);
self.storeData.iban_no = chIbn;
}
Html
<input type="text" name="din" (ngModelChange)="mychange($event)" class="form-control" [(ngModel)]="storeData.iban_no" required>
Console
input
need that hyphen value in input itself