2017-09-12 2 views
0

안녕하세요 여러분, 내 웹 앱에서 삭제 작업을 수행하려고합니다. DB에서 요소를 삭제할 때 콘솔에이 오류가 표시됩니다. 미리 감사드립니다. 이 내 코드입니다Uncaught TypeError : 정의되지 않은 속성 'attributes'을 읽을 수 없습니다.

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

줄 번호 1058에서 : :이 내 코드입니다

//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; 
    } 
}; 

행 번호 659에서 : 행 번호 888에서

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) 

이 내 코드입니다

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

전 스택 아웃을 확인했습니다. verflow, 난이 문제에 대한 적절한 해결책을 찾을 수 없습니다.

+0

디버그 코드를 & 왜'$ scope.orphanData.orphan' 점점되지 않은 데이터를 찾을 수 :

변경 사항은 확인해야합니다. –

+0

답장을 보내 주셔서 감사합니다 –

답변

1

즉, $scope.orphanData.orphanundefined입니다. 이 객체를 선언 한 위치를 찾고 객체를 참조하는지 확인하십시오.

+0

감사합니다. 답장을 보내 주셔서 감사합니다. –

0

개체의 속성에 액세스하려고하지만이 개체가 존재하지 않으므로이 오류가 발생합니다. 먼저 orphan 속성이 실제로 객체로 존재하는지 확인하여 attributes 속성에 액세스 할 수 있도록해야합니다.

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

감사합니다. @Aosis –

관련 문제