I have the below Select box
<select multiselect name="BodyColor.Default" [(ngModel)]="BodyColor.Default">
<option *ngFor="let z of BodyColor.Options" value={{z.OptionID}}>
{{z.OptionID}}
</option>
</select>
Is it possible to save this multiselect if BodyColor.Default
is of type string
.
I am using this as part of the JSON structure that I use for displaying data and I cannot change the data type for it.
Or is it just possible to change the datatype of BodyColor.Default
on demand when i want in the HTML file to array type.
Here is the JSON
"Attributes": [
{
"AttributeID": "Body Color",
"Options": [
{
"AttributeID": "Body Color",
"OptionID": "Aluminum",
"Description": "Aluminum",
"Position": 1.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "Black",
"Description": "Black",
"Position": 2.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "Blue Cobalt-2747C",
"Description": "Blue Cobalt-2747C",
"Position": 3.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "Blue Midnight-295C",
"Description": "Blue Midnight-295C",
"Position": 4.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "Blue-Costco-286C",
"Description": "Blue-Costco-286C",
"Position": 5.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "Blue-P2955C",
"Description": "Blue-P2955C",
"Position": 6.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "Camo",
"Description": "Camo",
"Position": 7.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "Chrome",
"Description": "Chrome",
"Position": 8.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "Cinnamon",
"Description": "Cinnamon",
"Position": 9.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "Copper",
"Description": "Copper",
"Position": 10.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "Green-357C",
"Description": "Green-357C",
"Position": 11.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "Gunmetal-7C",
"Description": "Gunmetal-7C",
"Position": 12.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "N/A",
"Description": "N/A",
"Position": 13.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "OD Green-7771C",
"Description": "OD Green-7771C",
"Position": 14.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "Onyx",
"Description": "Onyx",
"Position": 15.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "Orange",
"Description": "Orange",
"Position": 16.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "Pewter-6C",
"Description": "Pewter-6C",
"Position": 17.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "Platinum",
"Description": "Platinum",
"Position": 18.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "Red-200C",
"Description": "Red-200C",
"Position": 19.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "Red-202C",
"Description": "Red-202C",
"Position": 20.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "Slate-10C",
"Description": "Slate-10C",
"Position": 21.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "Stainless",
"Description": "Stainless",
"Position": 22.000000000,
"Default": false
},
{
"AttributeID": "Body Color",
"OptionID": "White",
"Description": "White",
"Position": 23.000000000,
"Default": false
}
],
"Description": "Body Color",
"InputType": "Multiple Select",
"Default": "",
"Required": false,
"EpicorOnly": false
},
Edit: So what seems to be happening is that it saving the data but throwing this error in AngularJS values.map is not a function. I see AngularJS convert the string into array automatically and saves the value but then later throws this error.
Can you try changing the datatype to be either string or an array? Example: private Testing: string[] | string;
private Testing: string[] | string;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.