-
Notifications
You must be signed in to change notification settings - Fork 442
NgModel modes. #126
Comments
Hi, just to clarify: you're asking if when binding select2 to an array of objects, if you can make ng-model be the selected object's id? |
Hi, yes. |
Hi I have same/similar question. same as http://stackoverflow.com/questions/14985346/setting-initial-values-of-angular-ui-select2-multiple-directive What I expect is, if we feed a collection as options and and the initial selection (akin to |
Any updates on this? I'm doing what I thought was a simple ng-model = array of selected items to initialize the select2 element, and at some point it recognizes them because the selected items are omitted from the options, but they don't show up as tags. |
OK, got it working with the initSelection: initSelection : function (element, callback) { But I'm with bsr203, feels a bit hacky. |
there is a simple_tags option that when set to true assigns the object's id instead of the object itself to the model |
@fghibellini |
but it seems to work only when you have a multiple choice input |
@fghibellini simple_tags is as the name says only for tags-feature, which only gets in place when isSelect = false so the convertToAngularModel and convertToSelect2Model Functions getting called. |
Any update on that? |
This is really a huge pain in the ass haha |
I have done a pull request which fixes this issue. ng-model binds to the id returned by select2 and it also allows you to bind a property in your controller to the select2 data object using a ui-data attribute. Check it out and let me know what you think: |
Any updates? we load select2 with ajax array of objects, but want objects id to be bound to model |
This project is deprecated. Fixes and new features are very unlikel yto happen. You should instead consider a migration to ui-select. |
Is there an option to set ngModel not to a selected object, but to desired object property/item id?
The text was updated successfully, but these errors were encountered: