I am trying to create a new json object (selectedProductAttributes) that is created when the contents of a 2nd json object (selectedProductAttributesNames) are compaired against a 3rd object (allProductAttributes)! To explain in more detail I have some examples below
The first one called allProductAttributes is a json object that contains differnt attributes for form fields
$scope.allProductAttributes = [
{
name: 'postcode',
title: 'Postcode',
required: true,
type: 'text',
max: '10',
placeholder: 'Enter a postcode'
},
{
name: 'Term',
title: 'Contract term',
required: true,
type: 'number',
},
{
name: 'bandwidth',
title: 'bandwidth',
type: 'select',
options: [
{id: 10, name: '10 mb/s'},
{id: 100, name: '100 mb/s'},
{id: 1000, name: '1000 mb/s'},
{id: 10000, name: '10000 mb/s'}
]
},
{
name: 'service',
title: 'Service',
required: true,
}
]
The next json object, selectedProductAttributesNames, contains a list of the form fields that the user wants to select from allProductAttributes
$scope.selectedProductAttributesNames = [
"postcode",
"service"
]
So from the above example, when the user requests 'postcode' and 'service' in selectedProductAttributesNames, a new json object should be created containing the form field attributes from allProductAttributes...
$scope.selectedProductAttributes = [
{
name: 'postcode',
title: 'Postcode',
required: true,
type: 'text',
max: '10',
placeholder: 'Enter a postcode'
},
{
name: 'service',
title: 'Service',
required: true,
}
]
I'm sorry if I have confused you. Does anyone know how I can achieve this? Thanks