angularJS如何操纵决心回归

时间:2015-12-30 17:52:24

标签: javascript angularjs restangular

我正在使用AngularJS和RESTAngularJS。 我的决心返回正确的JSON。例如“主题”

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"}

当我分配时,如下所示

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

我得到的结果如下

[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
}

如何摆脱像

这样的额外字段
 "reqParams":null,
 "restangularized":true,
 "fromServer":true, 
 "parentResource":null,
 "restangularCollection":false,

或者我做错了什么?

1 个答案:

答案 0 :(得分:0)

使用restangular中的plain方法去除它们。

像: $scope.SecondItems.plain();

请参阅https://github.com/mgonto/restangular