I am new to AngularJS and have this following piece of code that I need to edit.
scope.findData = [];
scope.clientId;
scope.identityDocuments_a = [];
scope.getClientIdentityDocuments_a = function(clientID){
resourceFactory.clientResource.getAllClientDocuments({clientId: clientID, anotherresource: 'identifiers'}, function(data){
scope.identityDocuments_a = data;
});
};
scope.findOptions = function(value){
var i;
var deferred = $q.defer();
resourceFactory.clientResource.getAllClientsWithoutLimit({displayName: value, orderBy : 'id', officeId : scope.group.officeId, sortOrder : 'ASC', orphansOnly : true}, function (data) {
deferred.resolve(data.pageItems);
for (i = 0; i <= data.pageItems.length; i++) {
scope.clientId = data.pageItems[i].id;
scope.getClientIdentityDocuments_a(scope.clientId);
//<- I want to access scope.identityDocuments_a here
}
scope.findData = data.pageItems;
});
return deferred.promise;
};
Both these functions are under the same controller. I looked at Accessing $scope variable from another method in the same controller Angularjs but it doesn't seem to work. Where am I going wrong? Thanks in advance.
clientId: scope.clientID
– Beartums Jan 30 at 5:57