Reputation: 167
In the below code, 'info' object has a description, quantity, value. How to give them as an array(Indo property). How to retrieve in angular code.
details.customsDetail.itemDetails = {
currency : "2000USD",
weight : "lbs",
info : {
description : "descr",
quantity : "2",
value : "124",
}
};
Upvotes: 0
Views: 1416
Reputation: 41447
you can assign the object to a variable and later you can push it to an array.
var backUp = angular.copy($scope.details.customsDetail.itemDetails.info);
$scope.details.customsDetail.itemDetails.info = [];
$scope.details.customsDetail.itemDetails.info.push(backUp);
console.log($scope.details.customsDetail.itemDetails)
angular.module("app",[])
.controller("ctrl",function($scope){
$scope.details = {"customsDetail":{"itemDetails":{}}};
$scope.details.customsDetail.itemDetails = {
currency : "2000USD",
weight : "lbs",
info : {// How to give this in a array.
description : "descr",
quantity : "2",
value : "124",
}
};
var backUp = angular.copy($scope.details.customsDetail.itemDetails.info);
$scope.details.customsDetail.itemDetails.info = [];
$scope.details.customsDetail.itemDetails.info.push(backUp);
console.log($scope.details.customsDetail.itemDetails)
})
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="ctrl">
</div>
Upvotes: 1
Reputation: 12103
Do you mean , indo property as array of objects?
details.customsDetail.itemDetails = {
currency : "2000USD",
weight : "lbs",
info : [{ // How to give this in a array.
description : "descr",
quantity : "2",
value : "124",
}]
};
Upvotes: 3