1

I was attempting to add an array to the parse.com backend. I created an array:

  var addHoles = function () {
    $scope.holeArray = [];
    for (var i = 0; i < 18; i++) {
        $scope.holeArray[i] = {
            number: i + 1,
            par: '',
            distance: '',
            handicap: ''
        };
    }
    console.log($scope.holeArray);
    return $scope.holeArray;
};

and then used ng-repeat to display the array and ng-model to allow the user to change the array.

      <div ng-repeat="hole in holeArray" class="row">
                        <div class="form-group">
                            <div class="col-md-2">
                                <div class="form-group form-md-line-input">
                                    <input type="text" class="form-control" id="form_control_1" ng-model="hole.number" readonly>
                                    <label for="form_control_1">Hole Number</label>
                                </div>
                            </div>

I was getting an unusual error from parse. and could not get parse to save the array.

1 Answer 1

1

It turns out the issue was that when you use ng-repeat angularjs adds a $$hashKey. This $$hasKey conflicts with parse's backend formatting requirements. So, to fix the issue all I had to do was use "track by" in my ng-repeat.

<div ng-repeat="hole in holeArray track by hole.number" class="row">

This took me hours to figure out. Hopefully it saves someone else time and headache.

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.