$scope.addUserJson = $scope.adduser;
console.log($scope.addUserJson);
Output
Object {"username":"Mik911","firstname":"Mike","lastname":"Angel","email":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="563b3f3d16313b373f3a7835393b">[email protected]</a>"}
$scope.usergroup = $scope.usergroupmodel;
console.log($scope.usergroup);
Output
[Object{"grpid":"1","username":"Vikram911","firstname":"Vikram","lastname":"Doe","email":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ef998684af88828e8683c18c8082">[email protected]</a>","gender":"Male",
"description":"BLAH BLAH","phone":"5858585"},{"grpid":"2","username":"Varun091","firstname":"Varun","lastname":"Doe",
"email":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="83f5e2f1f6edc3e4eee2eaefade0ecee">[email protected]</a>","gender":"Male","description":"BLAH BLAH","phone":"898989"}]
Merging two objects
$scope.object = angular.toJson(angular.merge({}, $scope.usergroup, $scope.addUserJson));
console.log($scope.object);
Output
[{"grpid":"1","username":"Vikram911","firstname":"Vikram","lastname":"Doe","email":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a4d2cdcfe4c3c9c5cdc88ac7cbc9">[email protected]</a>","gender":"Male",
"description":"BLAH BLAH","phone":"5858585"},{"grpid":"2","username":"Varun091","firstname":"Varun","lastname":"Doe",
"email":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a7d1c6d5d2c9e7c0cac6cecb89c4c8ca">[email protected]</a>","gender":"Male","description":"BLAH BLAH","phone":"898989"}]
Combining the above two JSON responses to create a final result as shown below:
{"username":"Mik911","firstname":"Mike","lastname":"Angel","email":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c3aeaaa883a4aea2aaafeda0acae">[email protected]</a>","grpid":["1,2"]}