boneskull / angular-tags

Pure AngularJS tagging widget with typeahead support courtesy of ui-bootstrap
MIT License
133 stars 32 forks source link

Model data format not being respected #18

Open ravinggenius opened 10 years ago

ravinggenius commented 10 years ago

Is there a way to specify the expected model format? If I don't make changes to the tags, I get back what I put in, but when I do make changes, I always get back an array of objects. I want the model to always be an array of strings, possibly empty. I've looked at the documentation, and didn't see a way to force a model format.

You may have noticed by now, but I am having some other issues also (#16 and #17, specifically). Thanks for the help.

In my view:

<tags data-options="{addable: true}" typeahead-options="typeaheadOpts" data-model="document.tags"></tags>
boneskull commented 10 years ago

@ravinggenius What is the model of document.tags? Originally we had behavior that would ensure you got a string back if you passed it a string, but this was failing if you gave it a blank array, since it wouldn't know whether or not that was an array of strings or an array of objects. So that needs to be fixed.

ravinggenius commented 10 years ago

Initially the model is an empty array or an array of strings. If I make changes (remove a tag or add a new tag), the model gets turned into an array of objects. Each object looks something like { $$hashKey: "051", name: "All Sites" }.

boneskull commented 10 years ago

Ok, right. @ravinggenius how would you like it to work? Maybe specifying a modalFormat attribute that is one of:

ravinggenius commented 10 years ago

What would you think of these choices for modelFormat:

I like the shorter names, so long as they don't obscure meaning. Otherwise this is exactly what I was asking for! Thanks for helping me out with this!