I am creating a configurator in AngularJS that uses the $ scope.data strong> object to allow users to edit the object through the front-end. Then the user can save this object in a separate array in $ scope.builds , which allows them to have several configurations. Here is a function that adds another configuration to $ scope.builds .
$scope.addition = function(){
var newData = angular.copy($scope.data);
$scope.builds.push(newData);
}
Unfortunately, despite using the angular.copy function , all objects in the $ scope.builds array seem to be the same $ scope.data strong> object repeats over and over.
EDIT:
Here is a shortened version of what $ scope.data strong> looks like :
$scope.data = [
{
'title': 'Select your configuration',
'required': true,
'options': [
{
'name': 'Option 1',
'select': true,
'filter': true
}, {
'name': 'Option 2',
'select': false,
'filter': true
}, {
'name': 'Option 3',
'select': false,
'filter': true
}
]
}, {
'title': 'Select your configuration',
'required': true,
'options': [
{
'name': 'Option 1',
'select': true,
'filter': true
}, {
'name': 'Option 2',
'select': false,
'filter': true
}, {
'name': 'Option 3',
'select': false,
'filter': true
}
]
}
];
source
share