编辑电话号码会使光标跳到最后 . 任何建议都将是一个很大的帮助 . 我按照提到的确切步骤进行操作:http://www.coderbro.com/angular2/2017/04/21/format-phone-number-in-form-input-with-angular2.html

我的代码:

HTML和组件类:

input type =“text”class =“input-underline-blue”id =“phone”formcontrolname =“phone”placeholder =“(123)345-2222”[textmask] =“{mask:mask}”pattern =“( ?(\ d {3}))?[\ n - ]?\ d {3} [\ s - ]?\ d {4})/“required =”“/>

mask : any[] = ['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/];