angularJS how to manipulate resolve returm

Issue

I am using AngularJS and RESTAngularJS.
My resolve return correct JSON. for example “subject”

0: {subjectId: "1", subjectCode: null, subjectLongName: "English", subjectShortName: "English"}
1: {subjectId: "2", subjectCode: null, subjectLongName: "Hindi", subjectShortName: "Hindi"}
2: {subjectId: "3", subjectCode: null, subjectLongName: "Maths", subjectShortName: "Maths"}
3: {subjectId: "4", subjectCode: null, subjectLongName: "Physics", subjectShortName: "Physics"}
4: {subjectId: "5", subjectCode: null, subjectLongName: "Chemistry", subjectShortName: "Chemistry"}

when I am assigning to, as below

$scope.SecondItems = subject; 
console.log($scope.SecondItems);

I am getting result as following

[Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, route: "subject", reqParams: null, restangularized: true, fromServer: true, parentResource: null…]


{
  "subjectId":"3",
  "subjectCode":null,
  "subjectLongName":"Maths",
  "subjectShortName":"Maths",
  "subjectDescription":null,
  "route":"subject",
  "reqParams":null,
  "restangularized":true,
  "fromServer":true,
  "parentResource":null,
  "restangularCollection":false,
  "IsSelected":true
}

How get rid of extra fields like

 "reqParams":null,
 "restangularized":true,
 "fromServer":true, 
 "parentResource":null,
 "restangularCollection":false,

OR what wrong I am doing?

Solution

Use the plain method from restangular to get rid of them.

Like:
$scope.SecondItems.plain();

See https://github.com/mgonto/restangular

Answered By – srcrustaceo

Answer Checked By – David Goodson (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.