Attempting to implement an authentication service in my application, I encountered an error when trying to call it within my controller:
!JavaScript ERROR: [$injector:unpr] Unknown provider: AuthenticationServiceProvider <- AuthenticationService <- loginControl
http://errors.angularjs.org/1.3.13/$injector/unpr?p0=AuthenticationServiceProvider%20%3C-%20AuthenticationService%20%3C-%20loginControl
http://localhost:53512/lib/ionic/js/ionic.bundle.js:12696
The service was created using the .factory
method, as shown below:
'use strict';
angular.module('pocket.login', ['ionic'])
.factory('AuthenticationService',
['Base64', '$http', '$cookieStore', '$rootScope', '$timeout',
function (Base64, $http, $cookieStore, $rootScope, $timeout) {
//Code goes here
}])
Additionally, the associated controller code is as follows:
'use strict';
angular.module('pocket.login', ['ionic'])
.controller('loginControl', function($rootScope,$scope,$http,$state,$ionicLoading,$cookieStore,AuthenticationService) {
//Example of calling the service
AuthenticationService.SetCredentials($scope.username, $scope.password);
});
Despite declaring the Controller and Service in the app.js file, the issue still persists:
'use strict';
angular.module('pocket.login', []);
angular.module('pocket', ['ionic',
'ngCordova', 'ui.bootstrap', 'ngIdle', 'ngCookies',
'pocket.welcome', 'pocket.registration',
'pocket.login', 'pocket.navigation', 'pocket.account',
'pocket.about'
])
If anyone can assist me in properly injecting the service, I would greatly appreciate it.
Regards,