What is the $$hashKey added to my JSON.stringify result

Angular adds this to keep track of your changes, so it knows when it needs to update the DOM.

If you use angular.toJson(obj) instead of JSON.stringify(obj) then Angular will strip out these internal-use values for you.

Also, if you change your repeat expression to use the track by {uniqueProperty} suffix, Angular won’t have to add $$hashKey at all. For example

<ul>
    <li ng-repeat="link in navLinks track by link.href">
        <a ng-href="https://stackoverflow.com/questions/18826320/link.href">{{link.title}}</a>
    </li>
</ul>

Just always remember you need the “link.” part of the expression – I always tend to forget that. Just track by href will surely not work.

Leave a Comment