Comments (17)
If you follow the example you can understand how to do it.
Your ng-model
should be set to an array that contains the tracking properties for the array bound in ng-options
.
<select
ng-model="model"
ng-options="obj as obj.text for obj in list track by obj.id"
...
from angular-bootstrap-duallistbox.
Sir, I am using the array to track properties, but unsure on following items
- How to select specific object data viz, id or text ?
- How to keep that specific option selected ?
<select
ng-model="model"
ng-options="obj as obj.text for obj in list track by obj.id"
multiple
...
<h3>You have selected: {{model}}</h3>
Shows You have selected: [{"id":"_1","text":"one"}], but not id or text.
from angular-bootstrap-duallistbox.
Sorry, I forgot how the inner parts work, haven't worked on this for a while.
The first part tells you what's going into the model, in this case the whole obj
, if you only want the IDs in the model, then use ng-options="obj.id as obj.text for obj in list track by obj.id"
from angular-bootstrap-duallistbox.
Okay, i can see obj.id
selected, but not the options which are clicked do not move to right side.
See the image below
from angular-bootstrap-duallistbox.
I need a live demo to help you with that. You can use plunker.
from angular-bootstrap-duallistbox.
here you go sir - http://plnkr.co/edit/gjGqAfXImH8tIW2stERj?p=preview
from angular-bootstrap-duallistbox.
As I already told you, you do not have to put my directive twice. Just use the file in the dist folder, do not put the module again.
from angular-bootstrap-duallistbox.
Sir, pls let me know where I have put your directive twice and which file I am suppose to remove ? I have changed setting of plunker. You can now edit.
from angular-bootstrap-duallistbox.
This is the proper way to do it: http://plnkr.co/edit/Yk49QLBZXGuT0ntASM4i?p=preview
Apparently you can't use the obj.id
notation, the model will contain the whole object, but it works.
from angular-bootstrap-duallistbox.
Yes the model does contain the whole object. But then my question remains the same. On saving the form, how can I fetch selected (post) data and on editing the page, how can I make the options selected as asked above ?
from angular-bootstrap-duallistbox.
You need to set your model yourself right after loading the list.
from angular-bootstrap-duallistbox.
I was able to achieve the above using ng-options="ugrp.id as ugrp.username for ugrp in userGroup"
but how can I show already selected option values in _helper2
i.e. right side on page load ? Then user can again select few more from left side and then save it ?
Plunker - http://plnkr.co/edit/Yk49QLBZXGuT0ntASM4i?p=preview
from angular-bootstrap-duallistbox.
You can't use ugrp.id
, you need to use ugrp
, please see my latest plunker I linked you. Did you open it?
from angular-bootstrap-duallistbox.
Sir, your plunker works well, but I need to fetch the id's for user group when form is submitted. So in my plunker it gives only id of usergroup like below
{"username":"911","firstname":"John","lastname":"P","email":"[email protected]","usergroup":["1","3"]}
But question is how to show that id 1,3 on right side i.e.
<select multiple="multiple" id="bootstrap-duallistbox-selected-list_" class="form-control" name="_helper2" style="height: 162px;"><option label="John" value="string:1" data-sortindex="0">John</option><option label="Doe" value="string:3" data-sortindex="1">Doe</option></select>
from angular-bootstrap-duallistbox.
As I have already told you
You need to set your model yourself right after loading the list.
http://plnkr.co/edit/kJj2WB?p=preview
from angular-bootstrap-duallistbox.
How about showing more than one field selected on right side. Below code does not work.
// THIS PRELOADS YOUR MODEL
$scope.model = [{
'id': '_1,_2',
'text': 'one'
}];
Or is there any other convention to use for multiple records ?
from angular-bootstrap-duallistbox.
Hi frapontillo,
if you could please respond to my above question, would be helpful,
Thanks.
from angular-bootstrap-duallistbox.
Related Issues (20)
- Postfix helpers HOT 1
- doesnt update model variable HOT 8
- "selectOrMinimalHeight" wrong variable name problem HOT 1
- info-all = 'false' attribute not working HOT 4
- DuallistBox - select one move all values HOT 1
- Required attribute gives error HOT 1
- How to set initial selected items? HOT 3
- Know when the NonSelected list box is empty HOT 3
- Large number of records and performance. HOT 1
- Use npm HOT 6
- Dependencies in index.html HOT 1
- Two-way binding to ng-model does not work HOT 2
- ng-model is not working for me HOT 2
- How to focus filter and item select HOT 1
- angular 4 HOT 1
- Tooltip on items HOT 2
- Avoid scroll on selection HOT 3
- Cannot populate the list of selected items from the controller HOT 7
- Example doesn't work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-bootstrap-duallistbox.