angular-tags icon indicating copy to clipboard operation
angular-tags copied to clipboard

Model data format not being respected

Open ravinggenius opened this issue 10 years ago • 4 comments

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>

ravinggenius avatar Oct 18 '13 16:10 ravinggenius

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

boneskull avatar Oct 18 '13 17:10 boneskull

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" }.

ravinggenius avatar Oct 18 '13 17:10 ravinggenius

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

  • auto automatically attempt to determine model format. defaults to an array of strings (?)
  • string will keep your model a delimited string
  • arrayOfStrings will keep your model an array of strings
  • arrayOfObjects will keep your model an array of objects

boneskull avatar Oct 18 '13 21:10 boneskull

What would you think of these choices for modelFormat:

  • auto automatically attempt to determine model format. defaults to an array of strings (?)
  • delimitedString will keep your model a delimited string
  • strings will keep your model an array of strings
  • objects will keep your model an array of objects

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!

ravinggenius avatar Oct 19 '13 01:10 ravinggenius