vitalets / angular-xeditable

Edit in place for AngularJS
http://vitalets.github.io/angular-xeditable
MIT License
1.91k stars 404 forks source link

How to save empty ng-tags-input as array? #766

Open sinall opened 4 years ago

sinall commented 4 years ago

If the model is not predefined, is there a way to save empty ng-tags-input as array? Here's the demo showing that ng-tags-input leaves model as undefined.

I also tried to reset the value in onbeforesave, but it didn't work.

In my case, the model is build dynamically based an other models, so it is not possible to initialize the model as empty array. So I'm trying to find a easy way to give it a default value. Currently I check and reset the model in save method of the form.

ckosloski commented 4 years ago

Yeah, there isn't really a good way to overwrite the model data on save (see comments in #736)

Resetting the model in save seems like your best bet.

sinall commented 4 years ago

@ckosloski So firstly should xeditable inputs save to model regardless the input text/value is empty or not? I mean do you consider this behavior a defect or it is by design? Currently I reset the model in save method, I was expecting the ng-tags-input do it implictly.