As a novice in AngularJS, I am currently working on a simple application.
This is the HTML code snippet that I am dealing with:
<table class="table" ng-repeat="(attr, assets) in customize.product.attributes">
<tr>
<th colspan="2">{{attr}}</th>
</tr>
<tr ng-repeat="asset in assets">
<td>
{{asset}}
</td>
<td>
<file-uploader class="form-control"
image-width="{{galleryConfigs.width}}"
image-height="{{galleryConfigs.height}}"
image-crop-width="{{galleryConfigs.width}}"
image-crop-height="{{galleryConfigs.height}}"
max-size="5000"
allowed-extensions="png,jpeg,jpg"
result-model="customize.assets[attr][asset]">
</file-uploader>
</td>
</tr>
</table>
And this is my JavaScript code:
$scope.create = function(published){
var published = published || false,
customize = angular.copy($scope.customize);
if(published)
customize.published = true;
dataProvider.Customize.save(customize).$promise
.then(function(_customize){
if(!_customize) throw 'Error System';
toast.create({content:'Succes', className:'success'});
$state.go('pos.product.customize.show',{customizeId:_customize.id});
}).catch(function (error){
$log.error(error);
});
};
When I save the data, it ends up being stored like this:
"assets" : {
"part 1" : {
"black" : [
"/file/c36a3297-11bb-4028-8cb7-d750b98436ec.png",
...
],
"red" : [
"/file/c36a3297-11bb-4028-8cb7-d750b98145ec.png",
...
]
}
}
However, I wish to save the data in the following structure:
"assets" : {
"part 1" : {
"black" :"/file/a11c553f-de74-48e2-93a0-6fc72a54fa9b.png",
"red" :"/file/a11c553f-de74-48e2-93a0-6fc72a54ga8c.png"
}
}
Is there any way to achieve this?