最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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': {}}
发布评论

评论列表(0)

  1. 暂无评论