javascript - Uncaught TypeError: Cannot read property 'attributes' of undefined - Stack Overflow

Hello everyone i am trying to perform delete operation in my web app,when i am deleting an element from

Hello everyone i am trying to perform delete operation in my web app,when i am deleting an element from DB, in console its showing this error.Please give your valuable solution for this Thanks in advance.

Uncaught TypeError: Cannot read property 'attributes' of undefined
at _clearTreeSelection (orphanController.js:888)
at Scope.$scope.clearSelection (orphanController.js:659)
at HTMLDivElement.<anonymous> (orphanController.js:1058)

at line number 888 this is my code:

//This is to clear the selectedNode of angular tree on modal close
_clearTreeSelection = function () {
$scope.orphanData.orphanText = 
$scope.orphanData.orphan.attributes.text;//This is line no.888
if ($scope.OntologyTree && $scope.OntologyTree.currentNode) {
        $scope.OntologyTree.currentNode = null;
    }
};

at line number 659 this is my code:

$scope.clearSelection = function () {
    _clearTreeSelection();//line no.659
    _clearGazetteerSelection();
};

at line number 1058 this is my code:

_modal.on('hidden.bs.modal', function () {
    $scope.suggestionListSearchText = '';
        $scope.clearSelection();// line no. 1058
    });
}

I have checked all over stackoverflow, i cant find the suitable solution for this problem.

Hello everyone i am trying to perform delete operation in my web app,when i am deleting an element from DB, in console its showing this error.Please give your valuable solution for this Thanks in advance.

Uncaught TypeError: Cannot read property 'attributes' of undefined
at _clearTreeSelection (orphanController.js:888)
at Scope.$scope.clearSelection (orphanController.js:659)
at HTMLDivElement.<anonymous> (orphanController.js:1058)

at line number 888 this is my code:

//This is to clear the selectedNode of angular tree on modal close
_clearTreeSelection = function () {
$scope.orphanData.orphanText = 
$scope.orphanData.orphan.attributes.text;//This is line no.888
if ($scope.OntologyTree && $scope.OntologyTree.currentNode) {
        $scope.OntologyTree.currentNode = null;
    }
};

at line number 659 this is my code:

$scope.clearSelection = function () {
    _clearTreeSelection();//line no.659
    _clearGazetteerSelection();
};

at line number 1058 this is my code:

_modal.on('hidden.bs.modal', function () {
    $scope.suggestionListSearchText = '';
        $scope.clearSelection();// line no. 1058
    });
}

I have checked all over stackoverflow, i cant find the suitable solution for this problem.

Share Improve this question edited Sep 12, 2017 at 6:47 Haseeb Ibrar 4376 silver badges18 bronze badges asked Sep 12, 2017 at 5:31 user3308969user3308969 2
  • Debug your code & find out why $scope.orphanData.orphan is not getting data. – Tushar Walzade Commented Sep 12, 2017 at 5:37
  • Thanks for reply – user3308969 Commented Sep 12, 2017 at 6:01
Add a ment  | 

2 Answers 2

Reset to default 1

This means that your $scope.orphanData.orphan is undefined. Find where have you declared this object and be sure that it refers to an object.

You are getting this error since you are trying to access a property on a object but that object does not exist. You should first make sure that orphan property actually exists as an object so that you can access attributes property on it.

Changes you need to make:

$scope.orphanData.orphan = {'attributes': {}}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745240599a4618159.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信