angular-input-masks
angular-input-masks copied to clipboard
On undefined, CNPJ dosen`t update SCOPE
On pre-populated inputs, if scope has cnpj model equals a undefined, the scope is not being updated.
ref.: ui-br-cnpj-mask
// scope with data from MYSQL
console.log($scope.loja)
Object {
CNPJ: undefined
IDCidade: "193"
IDCliente: 2
IDLoja: 1
NomeLoja: "BROOKLIN"
StatusLoja: "ativa"
}
// html
<md-input-container md-no-float>
<input ng-model="loja.CNPJ" placeholder="CNPJ" type="text" ui-br-cnpj-mask>
</md-input-container>
Some news about this issue?
I have fix it with: String() return String(i.cnpj.validate(e)). It is not the right way, but it is an workaround.
8: [function(e, t, n) {
var r = e("string-mask"),
i = e("br-validations"),
s = e("mask-factory"),
a = new r("00.000.000/0000-00");
t.exports = s({
clearValue: function(e) {
return e.replace(/[^\d]/g, "").slice(0, 14)
},
format: function(e) {
return (a.apply(e) || "").trim().replace(/[^0-9]$/, "")
},
validations: {
cnpj: function(e) {
return String(i.cnpj.validate(e))
}
}
})
}, {
"br-validations": 1,
"mask-factory": "mask-factory",
"string-mask": 3
}]
which version of angularjs are you using?
@calebeaires when you use String() you're converting the boolean false value to the string "false", that is, the boolean true. Maybe the is invalid on the database. Please, refer to #190.