To retrieve user information, the factory
sends a request to the API using ApiRequest.sendRequest
:
(function() {
angular.module('isApp.user', [])
.factory('UserProfileFactory', function( $log, ApiRequest, dataUrls ) {
// User profile properties
var userProfile = {
token : null,
id : null,
name : null,
ifMode : null,
justReader : true,
debugApp : 'NO',
didTutorial : false,
showOnlyUnread : true,
markAsReadOnScroll : false,
tagLimit : null,
};
return {
// Methods for user profile management
};
// Login function
function logIn( user, passwd )
{
// Function logic here
}
... additional methods
});
})();
...
The service
includes functions sendRequest
and send
. The send
function requires the user token obtained through UserProfileFactory.getToken()
.
The presence of both send
and sendRequest
is due to ongoing code changes. While sendRequest
is used in this example, other parts of the code use send
. This temporary setup aims to maintain compatibility during transition.
(function() {
angular.module('isApp.api', [])
.service('ApiRequest', function($http, $log, $q, UserProfileFactory, toaster, LanguageTexts, dataUrls) {
// sendRequest and send functions definitions
function send( request )
{
// Send function logic
}
function sendRequest( request )
{
// sendRequest function logic
}
}]);
})();
An error related to circular dependency involving UserProfileFactory
and ApiRequest
has been encountered:
Error: [$injector:cdep] http://errors.angularjs.org/1.3.13/$injector/cdep?p0=UserProfileFactory%20%3C-%20ApiRequest%20%3C-%20UserProfileFactory
To resolve the circular dependency issue, the file order needs adjustment. Any insights on reordering these files would be appreciated. Thank you.