누구든지 내가 무엇을 놓치고 있는지 또는이 문제에 직면하고있는 실제 문제가 무엇인지 말해주십시오.동일한 컨트롤러에서 스코프에 액세스 할 수 없습니다. AngularJS
여기 내 컨트롤러입니다.
app.controller('UpdateLeadController', ['$scope', '$http', '$location', '$route', 'ProgramsFactory', 'CommonFactory', '$filter', 'ProcessFactory', 'Upload', '$routeParams', function($scope, $http, $location, $route, ProgramsFactory, CommonFactory, $filter, ProcessFactory, Upload, $routeParams) {
$scope.limit = 3;
$scope.loadMore = function() {
$scope.limit += 2;
}
$scope.programIs = 1;
ProgramsFactory.Getprogramslist(1).then(function(response) {
$scope.programs = response.data.data;
});
CommonFactory.Getclients().then(function(response) {
$scope.clients = response.data.data;
});
ProgramsFactory.Getmonths().then(function(response) {
$scope.months = response.data.data;
});
ProcessFactory.Getlead($routeParams.id).then(function(response){
$scope.lead = response.data.data; // here i've got the lead data from factory.
});
console.log($scope); // when i am printing this scope i am getting the object lead with all data.
console.log($scope.lead); // when i am trying to print this. it outputs as `Undefined`.
}]);
이 문제는 계속되었습니다. 모든 데이터는 HTML에서 액세스 할 수 있지만 지시문뿐만 아니라 컨트롤러에서도 가져올 수 없습니다. 지시문은 데이터를 정의되지 않은 것으로 제공합니다.
while printing scope i can see the object. but when i am trying to access that object it showing it's undefined.
시도했습니다. 여전히 같은 문제가 발생합니다. :( –
데이터 소스와 관련하여 문제가 없습니다. 공장 호출로 모든 데이터를 가져 왔지만 액세스 할 수 없습니다. –