Map ng-model array values with the object of ng-options for selected optionsHow do I set the value property in AngularJS' ng-options?Why does AngularJS include an empty option in select?how to set the default 'select' ng-model to an object?issues with select field's empty optionselect ng-options issue in angular jsng-options selects element at index 0, when ng-model is null (only after digest loop)Updating array used by ng-options, refresh selected objectng-options default option object is not selecting with an array of objectsangularjs select option with valueAngularJS ng-model array
Print the phrase "And she said, 'But that's his.'" using only the alphabet
Can you cover a cube with copies of this shape?
Interview was just a one hour panel. Got an offer the next day; do I accept or is this a red flag?
How did space travel spread through the galaxy?
How can a flywheel makes engine runs smoothly?
Is the infant mortality rate among African-American babies in Youngstown, Ohio greater than that of babies in Iran?
How to search for Android apps without ads?
At what temperature should the earth be cooked to prevent human infection?
Is it possible for underground bunkers on different continents to be connected?
How do I run a script as sudo at boot time on Ubuntu 18.04 Server?
How to sort human readable size
Is my research statement supposed to lead to papers in top journals?
How do I gain the trust of other PCs?
How to ask if I can mow my neighbor's lawn
Why are almost all the people in this orchestra recording wearing headphones with one ear on and one ear off?
Why is an array with a single number in it considered a number?
How could I create a situation in which a PC has to make a saving throw or be forced to pet a dog?
...and then she held the gun
How do CMB photons 'gain energy when they pass through normal regions of space with matter' and 'lose energy when they pass through voids'?
Is this set open or closed (or both?)
Basic power tool set for Home repair and simple projects
How to prevent cables getting intertwined
Using roof rails to set up hammock
Will users know a CardView is clickable?
Map ng-model array values with the object of ng-options for selected options
How do I set the value property in AngularJS' ng-options?Why does AngularJS include an empty option in select?how to set the default 'select' ng-model to an object?issues with select field's empty optionselect ng-options issue in angular jsng-options selects element at index 0, when ng-model is null (only after digest loop)Updating array used by ng-options, refresh selected objectng-options default option object is not selecting with an array of objectsangularjs select option with valueAngularJS ng-model array
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have following values:
campaign_sms_templates = [11,22];
and
templateSMSList = [
"id":11, "name":"test",
"id":12, "name":"test 12",
"id":22, "name":"test 22"
];
And angular code is like:
<select multiple="multiple"
ng-model="campaign_sms_templates"
ng-options="value as value.name for value in templateSMSList track by value.id">
</select>
But values are not selected on rendering. When I change campaign_sms_templates parameter values with:
campaign_sms_templates = [ "id":11, "id":22 ];
It works as objects matches and on rendering it displays selected values.
Can anyone help, how I can render selected options by using these values:
campaign_sms_templates = [11,22];
Please do let me know if is there anything need more clarifications.
angularjs components multi-select bootstrap-multiselect
add a comment |
I have following values:
campaign_sms_templates = [11,22];
and
templateSMSList = [
"id":11, "name":"test",
"id":12, "name":"test 12",
"id":22, "name":"test 22"
];
And angular code is like:
<select multiple="multiple"
ng-model="campaign_sms_templates"
ng-options="value as value.name for value in templateSMSList track by value.id">
</select>
But values are not selected on rendering. When I change campaign_sms_templates parameter values with:
campaign_sms_templates = [ "id":11, "id":22 ];
It works as objects matches and on rendering it displays selected values.
Can anyone help, how I can render selected options by using these values:
campaign_sms_templates = [11,22];
Please do let me know if is there anything need more clarifications.
angularjs components multi-select bootstrap-multiselect
well select works that way, do you mind mapping your array to array of objects before you bind to view .
– super cool
Mar 25 at 4:40
thanks @supercool just resolved the problem after spending lots of hours in this :( please check and share your feedback .
– Shadman
Mar 25 at 6:29
add a comment |
I have following values:
campaign_sms_templates = [11,22];
and
templateSMSList = [
"id":11, "name":"test",
"id":12, "name":"test 12",
"id":22, "name":"test 22"
];
And angular code is like:
<select multiple="multiple"
ng-model="campaign_sms_templates"
ng-options="value as value.name for value in templateSMSList track by value.id">
</select>
But values are not selected on rendering. When I change campaign_sms_templates parameter values with:
campaign_sms_templates = [ "id":11, "id":22 ];
It works as objects matches and on rendering it displays selected values.
Can anyone help, how I can render selected options by using these values:
campaign_sms_templates = [11,22];
Please do let me know if is there anything need more clarifications.
angularjs components multi-select bootstrap-multiselect
I have following values:
campaign_sms_templates = [11,22];
and
templateSMSList = [
"id":11, "name":"test",
"id":12, "name":"test 12",
"id":22, "name":"test 22"
];
And angular code is like:
<select multiple="multiple"
ng-model="campaign_sms_templates"
ng-options="value as value.name for value in templateSMSList track by value.id">
</select>
But values are not selected on rendering. When I change campaign_sms_templates parameter values with:
campaign_sms_templates = [ "id":11, "id":22 ];
It works as objects matches and on rendering it displays selected values.
Can anyone help, how I can render selected options by using these values:
campaign_sms_templates = [11,22];
Please do let me know if is there anything need more clarifications.
angularjs components multi-select bootstrap-multiselect
angularjs components multi-select bootstrap-multiselect
edited Mar 25 at 6:35
wentjun
5,6331422
5,6331422
asked Mar 25 at 3:34
ShadmanShadman
4922817
4922817
well select works that way, do you mind mapping your array to array of objects before you bind to view .
– super cool
Mar 25 at 4:40
thanks @supercool just resolved the problem after spending lots of hours in this :( please check and share your feedback .
– Shadman
Mar 25 at 6:29
add a comment |
well select works that way, do you mind mapping your array to array of objects before you bind to view .
– super cool
Mar 25 at 4:40
thanks @supercool just resolved the problem after spending lots of hours in this :( please check and share your feedback .
– Shadman
Mar 25 at 6:29
well select works that way, do you mind mapping your array to array of objects before you bind to view .
– super cool
Mar 25 at 4:40
well select works that way, do you mind mapping your array to array of objects before you bind to view .
– super cool
Mar 25 at 4:40
thanks @supercool just resolved the problem after spending lots of hours in this :( please check and share your feedback .
– Shadman
Mar 25 at 6:29
thanks @supercool just resolved the problem after spending lots of hours in this :( please check and share your feedback .
– Shadman
Mar 25 at 6:29
add a comment |
2 Answers
2
active
oldest
votes
After spending lots of time in this, now finally I have resolved this
<select multiple="multiple" ng-change="save(campaign_sms_templates)" ng-model="campaign_sms_templates">
<option value=[[field.id]] ng-repeat="field in templateSMSList" ng-selected="campaign_sms_templates.indexOf(field.id)!==-1">[[field.name]]</option>
</select>
It seems not a good practice but as I only want to save ids in my database documents so I did this.
Any feedback are welcome.
add a comment |
Use value.id as value.name for value:
<select multiple="multiple"
ng-model="campaign_sms_templates"
ng-options="value.id as value.name for value in templateSMSList">
</select>
Also leave out the track by expression as it is not needed and will break the directive.
For more information, see
AngularJS ng-options Directive API Reference -select asandtrack by.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55330947%2fmap-ng-model-array-values-with-the-object-of-ng-options-for-selected-options%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
After spending lots of time in this, now finally I have resolved this
<select multiple="multiple" ng-change="save(campaign_sms_templates)" ng-model="campaign_sms_templates">
<option value=[[field.id]] ng-repeat="field in templateSMSList" ng-selected="campaign_sms_templates.indexOf(field.id)!==-1">[[field.name]]</option>
</select>
It seems not a good practice but as I only want to save ids in my database documents so I did this.
Any feedback are welcome.
add a comment |
After spending lots of time in this, now finally I have resolved this
<select multiple="multiple" ng-change="save(campaign_sms_templates)" ng-model="campaign_sms_templates">
<option value=[[field.id]] ng-repeat="field in templateSMSList" ng-selected="campaign_sms_templates.indexOf(field.id)!==-1">[[field.name]]</option>
</select>
It seems not a good practice but as I only want to save ids in my database documents so I did this.
Any feedback are welcome.
add a comment |
After spending lots of time in this, now finally I have resolved this
<select multiple="multiple" ng-change="save(campaign_sms_templates)" ng-model="campaign_sms_templates">
<option value=[[field.id]] ng-repeat="field in templateSMSList" ng-selected="campaign_sms_templates.indexOf(field.id)!==-1">[[field.name]]</option>
</select>
It seems not a good practice but as I only want to save ids in my database documents so I did this.
Any feedback are welcome.
After spending lots of time in this, now finally I have resolved this
<select multiple="multiple" ng-change="save(campaign_sms_templates)" ng-model="campaign_sms_templates">
<option value=[[field.id]] ng-repeat="field in templateSMSList" ng-selected="campaign_sms_templates.indexOf(field.id)!==-1">[[field.name]]</option>
</select>
It seems not a good practice but as I only want to save ids in my database documents so I did this.
Any feedback are welcome.
answered Mar 25 at 6:28
ShadmanShadman
4922817
4922817
add a comment |
add a comment |
Use value.id as value.name for value:
<select multiple="multiple"
ng-model="campaign_sms_templates"
ng-options="value.id as value.name for value in templateSMSList">
</select>
Also leave out the track by expression as it is not needed and will break the directive.
For more information, see
AngularJS ng-options Directive API Reference -select asandtrack by.
add a comment |
Use value.id as value.name for value:
<select multiple="multiple"
ng-model="campaign_sms_templates"
ng-options="value.id as value.name for value in templateSMSList">
</select>
Also leave out the track by expression as it is not needed and will break the directive.
For more information, see
AngularJS ng-options Directive API Reference -select asandtrack by.
add a comment |
Use value.id as value.name for value:
<select multiple="multiple"
ng-model="campaign_sms_templates"
ng-options="value.id as value.name for value in templateSMSList">
</select>
Also leave out the track by expression as it is not needed and will break the directive.
For more information, see
AngularJS ng-options Directive API Reference -select asandtrack by.
Use value.id as value.name for value:
<select multiple="multiple"
ng-model="campaign_sms_templates"
ng-options="value.id as value.name for value in templateSMSList">
</select>
Also leave out the track by expression as it is not needed and will break the directive.
For more information, see
AngularJS ng-options Directive API Reference -select asandtrack by.
answered Mar 25 at 8:23
georgeawggeorgeawg
37.1k115473
37.1k115473
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55330947%2fmap-ng-model-array-values-with-the-object-of-ng-options-for-selected-options%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
well select works that way, do you mind mapping your array to array of objects before you bind to view .
– super cool
Mar 25 at 4:40
thanks @supercool just resolved the problem after spending lots of hours in this :( please check and share your feedback .
– Shadman
Mar 25 at 6:29