angular-ui-tree icon indicating copy to clipboard operation
angular-ui-tree copied to clipboard

Cannot read property '$$hashKey' of undefined

Open atheleron opened this issue 11 years ago • 8 comments

 TypeError: Cannot read property '$$hashKey' of undefined
    at Object.extend (http://local.dev/js/vendor/angular.js:407:14)
    at Scope.$scope.editCancel (http://local.dev/js/controllers/catCtrl.js:68:25)
    at new <anonymous> (http://local.dev/js/controllers/catCtrl.js:123:11)
    at Object.invoke (http://local.dev/js/vendor/angular.js:4180:17)
    at extend.instance (http://local.dev/js/vendor/angular.js:8439:21)
    at http://local.dev/js/vendor/angular.js:7691:13
    at forEach (http://local.dev/js/vendor/angular.js:331:20)
    at nodeLinkFn (http://local.dev/js/vendor/angular.js:7690:11)
    at compositeLinkFn (http://local.dev/js/vendor/angular.js:7073:13)
    at publicLinkFn (http://local.dev/js/vendor/angular.js:6952:30)

Is there a way to fix this ??

AngularJS v1.3.7 Angular UI Tree v2.1.5

atheleron avatar Dec 16 '14 12:12 atheleron

+1, also having this issue!

anselanza avatar Jan 06 '15 14:01 anselanza

You should post some code so we can see what you're trying to do. The array in your ng-repeat contains more than 0 elements?

andreaslarssen avatar Jun 12 '15 12:06 andreaslarssen

I guess you have a case like the following:

angular.extend(object1, object2);

In this situation if object1 is null or "undefined", then it breaks your flow and you get an exception.

So, you may consider initializing object1 as an empty object in the first place if there is no reason not to do.

i.e. object1 = {};

EmreErdogan avatar Oct 29 '15 10:10 EmreErdogan

@atheleron / @anselanza can you post a little more info about this issue? How can we reproduce the issue?

Voles avatar Nov 02 '15 20:11 Voles

Closed due to inactivity.

Voles avatar Dec 21 '15 08:12 Voles

Hi, i'm having this issue also. My issue is that angular requires me to put track by within my ng-repeat, but track by removes $$haskKey from the object.

andrew-donovan avatar Jun 16 '16 15:06 andrew-donovan

@lingthing5 Are you also using angular.extend() at some point? In this case, you might still have some null or undefined values in your array. You should check the content of your iterable and possibly filter out those invalid values. As an alternative you could also create a new object every time via angular.extend({}, yourOtherStuff, ...).

herrherrmann avatar Jan 23 '17 10:01 herrherrmann

Indeed.. @EmreErdogan Solved my problem.

A nice tip is to use ES6 Syntax and always initialize the function params. note: (params = {}) Im my case i had:

const someFunction = (params = {}) => {
    angular.extend(params, itemX, itemY);
    // ... logic
};

itsmelion avatar Jun 21 '18 21:06 itsmelion