AngularJS function undefined when uncommenting it -
i have weird problems related defintion of method inside scope. once it's defined, , when want call (just entering code) disappears. have part of code
if (configurationservice.isconfigurationchanged() === true) { configurationservice.getconfiguration().then(function(data) { $scope.configuration = data.configuration; $scope.lunchers = data.lunchers; $scope.configuration.vegies.all_in_one_group = data.configuration.vegies.all_in_one_group; var luncherslength = data.lunchers.all.length; (var = 0; < luncherslength; i++) { $scope.selectedvegies[i] = $scope.isvegie(data.lunchers.all[i]); $scope.selectedspecialgroup[i] = $scope.isinspecialgroup(data.lunchers.all[i]); $scope.isabsent[i] = $scope.isabsent(data.lunchers.all[i]); } }); } else if (configurationservice.isconfigurationchanged() === false) { var cached = configurationservice.getcachedconfiguration(); console.log($scope.isvegie); $scope.configuration = cached.configuration; $scope.lunchers = cached.lunchers; $scope.configuration.vegies.all_in_one_group = cached.configuration.vegies.all_in_one_group; var luncherslength = cached.lunchers.all.length; (var j = 0; j < luncherslength; j++) { $scope.selectedvegies[i] = $scope.isvegie(cached.lunchers.all[j]); //$scope.selectedspecialgroup[i] = $scope.isinspecialgroup(cached.lunchers.all[i]); //$scope.isabsent[i] = $scope.isabsent(cached.lunchers.all[i]); } }
now weird happens. can see:
console.log($scope.isvegie);
when have:
$scope.selectedvegies[i] = $scope.isvegie(cached.lunchers.all[j]);
commented can see method in firebug, when uncomment it, gets undefined...
anybody had similar issues?
note:
configurationservice.getconfiguration()
is method:
getconfiguration : function() { var deferred = $q.defer(); $http({ method :'get', url : "cgi-bin/get_configuration.py" }) .success(function(data, status, headers, config) { if (status === 200) { angular.copy(data, configstatus.currentconfig);// = data; configstatus.configurationchanged = false; deferred.resolve(data); } }) .error(function(data, status, headers, config) { console.log(data); console.log(status); deferred.reject(data); }); return deferred.promise; },
found issue. thing that
$scope.isvegie
was defined after logic calling it. however, didn't noticed when didn't have else part. when without if-else, working fine though method defined "under" logic calling it.
this solved issue.
Comments
Post a Comment