How to save Firebase $ asArray () objects using angularFire when objects contain ng-repetate

I recently switched from corner fire from 0.6 to 0.8. I'm having trouble saving the list item that contains the array itself.

My account objects are as follows:

{
  "-JQruasomekeys0nrXxH" : {
    "created" : "2014-03-23T22:00:10.176Z",
    "durations" : [ {
      "$$hashKey": "00L", // this is generated by ng-repeat on arrays
      "end" : "2014-07-15T22:00:00.000Z",
      "start" : "2014-07-09T22:00:00.000Z"
    } ],
    "email" : "some@mail.net",
  }
}

Duration is an array of time periods from the beginning and the end that resemble the ng repeat of two input fields in HTML.

<tr ng-repeat="duration in account.durations">
  <td>
     <input ng-model="duration.start" datepicker>
  </td>
  <td>
     <input ng-model="duration.end" datepicker>
  </td>
</tr>

Before saving the account in firebase, I do angular.copy ($ scope.account) in the controller to get rid of the hash values ​​of angular $$. This worked in angularfire 0.6.0.

In angularfire 0.8.0, I still get the error:

: Firebase.set: ($$ hashKey) 'durations.0'. ".", "#", "$", "/", "[", "]

, ? , . , angular.copy firebase angularfire?

.

(11 . 14) , , angular.copy() . . / $save() (https://www.firebase.com/docs/web/libraries/angular/api.html#angularfire-firebaseobject-save) $save() angular.copy().

2 (12 14) , :

// loop for every duration, that should clean the object from "$$hashKey" attributes
angular.forEach($scope.account.durations, function (value, index) {
  var cleanValue = {};

  // checks, if the date is a JSON string already
  if (typeof value.start === 'string') {
    cleanValue.start = value.start;
  } else {
    cleanValue.start = value.start.toJSON();
  }

  // checks, if the date is a JSON string already
  if (typeof value.end === 'string') {
    cleanValue.end = value.end;
  } else {
    cleanValue.end = value.end.toJSON();
  }

  // overwrite the array object at index to get loose of $$hashKey
  $scope.account.durations[index] = cleanValue;
});

, , , Firebase, , AngularFire.

3 (13. AUg 14) jsfiddle, : jsfiddle.net/1fem6byt

, firebase, $$ hashKey ( ). , , , . , - - ?

+4
1

, firebase, @Kato, , firebase $asArray.

: http://jsfiddle.net/RaVbaker/sb00kor8/1/ " " Save to Firebase, firebase. .

- angular ng-repeat. , track by $index ng-repeat.

ng-repeat="duration in account.durations" :

 ng-repeat="duration in account.durations track by $index"

jsfiddle : http://jsfiddle.net/RaVbaker/sb00kor8/2/

track by ngRepeat .

, .

+1

All Articles