Javascript 在组件上设置输入值时,角度imask不工作
我有个问题。我有一个使用Angular CLI版本7.3.6的项目。我正在使用角度imask格式化一些输入。在某种情况下,角度遮罩无法正常工作 对于表单,我使用FormGroup。 如代码所示加载人员时,有两种情况,一种是人员来自存储在服务中的变量,另一种是向后端发出请求。在这两种情况下,当返回person时,“this.pessoaForm.patchValue(this.pessoa)”用于设置表单输入中的person字段。但是,如果由第一个if(服务变量)设置时,字段的值的格式为“16893034108”,则从表单恢复时的值为“16893034108”。但是,如果字段的值来自后端(根据if),则从窗体恢复时的值为“(16)89303-4108”,即应用了掩码。我希望第一个选项也与应用的掩码一起提供,两种形式都由'this.pessoaForm.patchValue(this.pessoa)'完成。问题与此链接类似 链接:https://simb.github.io/textMaskDemo/ 有人知道这是一个bug还是需要进行一些配置吗Javascript 在组件上设置输入值时,角度imask不工作,javascript,angular,typescript,mask,angular-ui-mask,Javascript,Angular,Typescript,Mask,Angular Ui Mask,我有个问题。我有一个使用Angular CLI版本7.3.6的项目。我正在使用角度imask格式化一些输入。在某种情况下,角度遮罩无法正常工作 对于表单,我使用FormGroup。 如代码所示加载人员时,有两种情况,一种是人员来自存储在服务中的变量,另一种是向后端发出请求。在这两种情况下,当返回person时,“this.pessoaForm.patchValue(this.pessoa)”用于设置表单输入中的person字段。但是,如果由第一个if(服务变量)设置时,字段的值的格式为“1689
private loadPessoa() {
if(this.pessoaService.getPersonGuarded()){
this.pessoa = this.pessoaService.getPersonGuarded();
this.pessoaService.setPersonGuarded(null)
this.createFirstPerson = true
if(!(this.currenctAction == 'novo')){
this.disableCnpjOrCpf()
}
if(this.pessoa.empresa)
{
this.pessoaForm.get('cpf').disable()
this.pessoaForm.get('cnpj').disable()
this.pessoaForm.get('id_tipo_pessoa').disable()
this.pessoaForm.get('id_empresa').disable()
}
this.pessoaForm.patchValue(this.pessoa);
this.loadPersonFromPessoaService = true
}
else if (this.currenctAction == 'editar' || this.currenctAction == 'visualizar') {
this.route.paramMap.pipe(
switchMap(params => this.pessoaService.getById(params.get('uuid')))
).subscribe(
(pessoa) => {
this.pessoa = pessoa
this.disableCnpjOrCpf()
this.pessoaForm.patchValue(this.pessoa)
this.enderecoListComponent.getAddresses(this.pessoa.id_pessoa)
this.contatoListComponent.getContacts(this.pessoa.id_pessoa)
this.midiaListComponent.getMidias(this.pessoa.id_pessoa)
},
(error) => alert(error)
);
}
if(this.currentUser.id_empresa == ID_USER_ADMIN && !this.pessoa.empresa){
this.pessoaForm.get('id_empresa').setValidators([Validators.required])
this.pessoaForm.get('nome_empresa').setValidators([Validators.required])
if(this.currenctAction == 'novo')
{
this.pessoaForm.get('id_empresa').setValue(this.currentUser.id_empresa)
this.pessoaForm.get('nome_empresa').setValue(this.currentUser.nomeEmpresa)
}
this.pessoaForm.get('id_empresa').updateValueAndValidity()
this.pessoaForm.get('nome_empresa').updateValueAndValidity()
}
}
imaskFone = {
mask: '(00) 0000-0000',
placeholder: {
show: 'always'
}
};
“角度imask”:“^6.0.1”,