angular-input-masks icon indicating copy to clipboard operation
angular-input-masks copied to clipboard

[br-phone-number] valores inicializados em strings com os caracteres da máscara

Open rafael-augusto opened this issue 9 years ago • 6 comments

Ao inicializar um input com br-phone-number com um model com valor string já com máscara (ex : (11) 1223 - 3444), é necessário apagar qualquer caractere do input e re-digitálo para que o input se torne válido.

<input class="form-control" type="text" ng-model="OrdemServico.Telefone01" maxlength="20" name="Telefone01" ui-br-phone-number />

controller:

$scope.OrdemServico.Telefone01 = "(11) 1223-3444";

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

rafael-augusto avatar Feb 24 '16 13:02 rafael-augusto

What is the expected behavior in your opinion? To remove the mask characters in the initialization?

assisrafael avatar Mar 08 '16 21:03 assisrafael

Estou tendo um problema parecido, só que no meu caso o controller é:

$scope.OrdemServico.Telefone01 = "1112233444";

A input fica em branco.

ianldgs avatar May 30 '16 18:05 ianldgs

Same problem here.

There are any workaround?

andreasadelino avatar Feb 23 '18 15:02 andreasadelino

In my opinion, the modelValue should always have the mask (in the case of document, phones, etc). It's not like a currency that you need to perform mathematical operations on it. If you don't save the field masked in your database, how will you exibt it?

Say that some user registers with "en_us" locale, and the mask for the phone was the american. What if tomorrow he comes back to your website, but somehow the locale defaults to "pt_br", the mask will be wrong, because ou saved it as an integer.

In every field that has mask, you would have to save what mask it used on the database. And by so, you will need a library int the back-end that is compatible with the same mask used on the front-end.

Other problem: documents that starts with "0" (like mine), always get saved without the first digit.

ianldgs avatar Feb 27 '18 11:02 ianldgs

Same problem here. Is there an alternative that keeps the modelValue masked?

crivano avatar Sep 20 '18 22:09 crivano

Same here!

gustavo-sg avatar Jan 25 '19 20:01 gustavo-sg