0

Hello I'm trying to concat two JSON object to form a bigger json body. both these objects are form values which are assigned to a rootscope variable.

$rootScope.AString = angular.toJson(AModel);
    $rootScope.BString = angular.toJson(BModel);
    $rootScope.CString = BString.concat(AString);

But this does not work! I searched through all the documentation. there is no clear function to do this. please help!

3
  • 1
    Cant you do just a object with two properties: Amodel e Bmodel? Something like: $rootScope.model = { AModel: AModel, BModel: BModel }; Commented Nov 19, 2013 at 17:28
  • Look here stackoverflow.com/questions/17242927/… Should work Commented Nov 19, 2013 at 17:28
  • 2
    converting to json makes no sense Commented Nov 19, 2013 at 17:44

1 Answer 1

0

You can try this by using spread operator(es6), you will get the combined object of AModel and BModel at $rootScope.CModel.

$rootScope.CModel = {...$rootScope.AModel, ...$rootScope.BModel};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.