angularjs - set selected values in amitava82/angular-multiselect -
I'm new to angular and I need a multilevel box in my search form, I have to multiselect.js
But there is a problem that I have that when I want to load a saved item, I can not find the value selected in it.
This code is Multiselectbox
& lt; Multiselect class = "Input-normal" multi = "true" ng-model = "year list" option = "List of year data as year." List for years. YYListYearList in data "change =" and "selected ()" Gt; & Lt; / Select multiple & gt;
I use this line of code to reset it
$ scope.yearlist [0]. Checked = wrong;
this works fine
and this is the code that I try to use to set the values selected but it does not work
$ scope.yearlist = [{data: 2009, checked: true} {data: 2011, checked: true}];
How can I load this form with the predefined values selected?
I do not know that it also works in conjunction with 'amitava82 / angular-multiselect' But do I know that if the data handling is based on a default multi selection box with ng-option, then you have made a common mistake.
HTML for the default multi select:
& lt; Multiple NG-model = "year list" as option.data for option ng-option = "option.data select data in urllist" & gt; & Lt; / Select & gt;
If you have 'Datalist':
$ scope.dataYearList = [{"Data": 2014}, {"Data": 2013} {"Data": 2012}, {"Data": 2011}, {"Data": 2010}, {"Data": 2009}];
and your list is:
$ scope.yearlist = [{"Data": 2012}, {"Data": 2011}];
Your selection will not be selected in a multi-select box. But if you change the 'year list' to the following:
$ scope.yearlist = [2012, 2011];
Your selection will be selected.
Why? Because 'option.data as' option refers to the data value that is not, for example, {"data": 2012} but 2012.
Do you have 'option.data as' 'option' because then it will be, for example, {"data": 2012}. It will not work.
For some reason multiselect can not control the object arrays in the NG model or it can not be placed in the ng-option for 'option data'. Why, I'm not sure is.
Hope also helps you with your problem with 'Amitva 82 / Angel-Multislact'.
Comments
Post a Comment