发生异常的javascript错误有人可以帮我解决这个问题吗? 这是我的全部功能
$scope.getAllSubMilestones = function() {
if (typeof $scope.subMilestones == 'undefined' || $scope.subMilestones.length < 0 || $scope.subMilestones == '') {
// the array is defined and has at least one element
var URL = $window.sessionStorage.getItem('HOST_URL') + '/subMilestoneFormObjs';
function onSuccess(response) {
$scope.subMilestones = response.data;
pu_ws_counter++;
setTimeout(function() {
for (var i = 0; i < $scope.subMilestones.length; i++) {
var sub_milestone = $scope.subMilestones[i];
var selected_sub_milestone = $scope.project.projectSubMilestones;
if(selected_sub_milestone != null){
for (var j = 0; j < selected_sub_milestone.length; j++) {
var s = selected_sub_milestone[j];
if (sub_milestone.id == s.subMilestone.id) {
//document.getElementById('#' + sub_milestone.id).checked = true;
// $('#' + sub_milestone.id).prop('checked', true);
$('#' + sub_milestone.id).click();
}
}
}
}
我在这条线上收到错误
for (var j = 0; j < selected_sub_milestone.length; j++) {
错误说
未捕获的TypeError:无法读取null的属性'length'