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

On undefined, CNPJ dosen`t update SCOPE

Open calebeaires opened this issue 10 years ago • 4 comments

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>

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/25441852-on-undefined-cnpj-dosen-t-update-scope?utm_campaign=plugin&utm_content=tracker%2F1022469&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1022469&utm_medium=issues&utm_source=github).

calebeaires avatar Aug 06 '15 14:08 calebeaires

Some news about this issue?

calebeaires avatar Mar 16 '16 12:03 calebeaires

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
    }]

calebeaires avatar Mar 16 '16 13:03 calebeaires

which version of angularjs are you using?

assisrafael avatar May 21 '16 07:05 assisrafael

@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.

detinho avatar Jun 13 '16 01:06 detinho