Skip to content
This repository has been archived by the owner on Nov 22, 2021. It is now read-only.

Object passed to on-tag-added with use-strings="true" #874

Open
cgatesman opened this issue Nov 21, 2018 · 0 comments · May be fixed by #875
Open

Object passed to on-tag-added with use-strings="true" #874

cgatesman opened this issue Nov 21, 2018 · 0 comments · May be fixed by #875

Comments

@cgatesman
Copy link

cgatesman commented Nov 21, 2018

If you use use-strings="true" along with on-tag-added (or other callbacks), the $tag passed to the onTagAdded($tag) function is an object (e.g. {text: 'Tag Name'}) instead of just the tag name string. In addition to this, on the first tag add, the tagsInput model within the onTagAdded($tag) function call is an array of objects instead of an array of strings. On additional adds, the model in onTagAdded($tag) is the correct array of strings; however, it is missing the newly added tag.

One thing to note: If you put a $timeout in the onTagAdded($tag) function, the model is always correct after the $timeout.

cgatesman pushed a commit to NorthPage/ngTagsInput that referenced this issue Nov 27, 2018
Fixes mbenford#874

Several issues were found while debugging and fixing mbenford#874:

- Pass just tag name string to callback functions when using `use-strings="true"`
- Call callback functions in a `$timeout` to ensure model has been appropriately updated with just tag strings before the callback is called.  The model is updated in a watcher so it is asynchronously updated
- Use `$watchCollection` for tags watcher
- Do not clobber tags container when adding/removing items
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant