I am new to angular js and I'm attempting to create a custom service. I've copied and pasted some code for the custom service, but I keep encountering the following error:
Error: [$injector:unpr] Unknown provider: serviceProvider <- service <- MainController
http://errors.angularjs.org/1.4.3/$injector/unpr?p0=serviceProvider%20%3C- %20service%20%3C-%20MainController
at REGEX_STRING_REGEXP (angular.js:68)
at angular.js:4262
at Object.getService [as get] (angular.js:4409)
at angular.js:4267
at getService (angular.js:4409)
at Object.invoke (angular.js:4441)
at $get.extend.instance (angular.js:8999)
at nodeLinkFn (angular.js:8109)
at compositeLinkFn (angular.js:7541)
at publicLinkFn (angular.js:7416)(anonymous function) @ angular.js:12330
Here is the code for my custom service:
(function () {
var myModule = angular.module('app', ['onsen']);
myModule.service('service', ["$http", function ($http) {
var test = function (usertoken) {
alert("fffffffffffffffffffff");
}
return {
getUserSites: getUserSites
};
}]);
})();
And here is my module implementation :
(function () {
var myApp = angular.module('app', ['onsen']);
var MainController = function ($scope, $http, $interval, service) {
$scope.clciclme = function () {
alert("HIIIIIIIIIIIIIIIIIIII");
}
}
myApp.controller('MainController', MainController);
})();
I would appreciate any help in resolving this error. Thank you.