I am trying to combine response of one POST data with another input JSON so that it can do another POST function.
Controller 1:-
$scope.master = {};
$scope.addChild = function(net) {
$scope.master = angular.copy(net);
$http.post("url",$scope.master).then( function(data) {
$scope.childData = data;
$scope.dataName = $scope.master.Name;
growl.success("Created a new Child");
console.log(data);
},function (data, status, headers, config) {
growl.error("Something went wrong");
});
console.log($scope.master);
};
Now I want to add the response of this controller ie; $scope.segments = data;
to 2nd controller:-
Controller 2:-
$scope.addOverall = {Child: []};
$scope.Create = function() {
$http({
method : 'POST',
url : 'api',
data : $scope.addOverall
}).success(function(data, status, headers, config) {
growl.success("Created a Table");
console.log(data);
},function (data, status, headers, config) {
growl.error("Something is wrong");
});
};
So now , my response data from controller 1 must combine with 2nd controller input over here {Child: []};
inside the [ ] How can I achieve that?