1

One of the columns in my ng-repeat directive outputs the values of $$hashkey.

I have no idea how this started happening. I get data from a simple GET and inspecting that data as it gets in from the success callback shows the $$hashkey being inserted to each object. I understand the $$hashkey is used by angular but this never happened before as far as HTML view output goes.

This is on 1.2.16

$$haskey being output to view

HTTP GET:

$http.get('index.php/getWorkbook/'+$routeParams.workbook).success(function(data) {
    console.log(data); // Has $$hashkey inserted
    $scope.workbook = data;
});

HTML:

    <tr ng-repeat='row in workbook'>
        <td ng-repeat="key in notSorted(row)" ng-init="value = row[key]">
            <input type="text" ng-model="value" ng-blur="edit(value, key, row)" />
        </td>
    </tr>

Here is the controller function.

$scope.notSorted = function(obj){
    if (!obj) {
        return [];
    }
    return Object.keys(obj);
}
Dean Or
  • 2,822
  • 2
  • 26
  • 25
  • Did you upgrade angular recently? Change anything else? Have you always used Object.keys to get the property names? – aet Apr 07 '14 at 23:42
  • I use the 1.2.16 CDN. I'm not sure what happened. I use Object keys to prevent angular from sorting my columns. – Dean Or Apr 08 '14 at 18:36
  • Another solutions appears to be using track in ngRepeat - http://stackoverflow.com/a/23656919/1148107 – mtpultz Jul 30 '15 at 07:12

2 Answers2

3

Seems the rows don't like being ran through notSorted(). Adding angular.copy() ended up working for me.

$scope.notSorted = function(obj){
    obj = angular.copy(obj);

    if (!obj) {
        return [];
    }

    return Object.keys(obj);
}
Dean Or
  • 2,822
  • 2
  • 26
  • 25
1

Try this change in your controller

$scope.workbook = data;
$scope.workbook = angular.fromJson(angular.toJson($scope.workbook));
BKM
  • 6,949
  • 7
  • 30
  • 45