assisrafael / angular-input-masks

Opinionated input masks for AngularJS
http://assisrafael.github.io/angular-input-masks/
MIT License
963 stars 329 forks source link

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

Open rafael-augusto opened 8 years ago

rafael-augusto commented 8 years ago

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.

assisrafael commented 8 years ago

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

ianldgs commented 8 years ago

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

$scope.OrdemServico.Telefone01 = "1112233444";

A input fica em branco.

andreasadelino commented 6 years ago

Same problem here.

There are any workaround?

ianldgs commented 6 years ago

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.

crivano commented 6 years ago

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

gustavo-sg commented 5 years ago

Same here!