sliptree / bootstrap-tokenfield

A jQuery tag/token input plugin for Twitter's Bootstrap, by the guys from Sliptree
http://sliptree.github.io/bootstrap-tokenfield/
Other
859 stars 238 forks source link

Not able to set object value while using Angular #283

Open nikhilsarvaiye opened 8 years ago

nikhilsarvaiye commented 8 years ago

Hi,

I have seen below lines of code which was making value to string in every case,

// Normalize label and value attrs.value = $.trim(attrs.value.toString()); attrs.label = attrs.label && attrs.label.length ? $.trim(attrs.label) : attrs.value

    // Bail out if has no value or label, or label is too short
    if (!attrs.value.length || !attrs.label.length || attrs.label.length <= this.options.minLength) return

which we can make it to

// Normalize label and value attrs.value = typeof attrs.value === 'string' ? $.trim(attrs.value.toString()) : attrs.value; attrs.label = attrs.label && attrs.label.length ? $.trim(attrs.label) : attrs.value

    // Bail out if has no value or label, or label is too short
    if(typeof attrs.value === 'string')
        if (!attrs.value.length || !attrs.label.length || attrs.label.length <= this.options.minLength) return

The problem will be in case of using Angular and Ng - Model as object Please add support for it, currently we are abel to do the same in create token event