I am new to Angular.js and writing a custom service for my application.
About my application: It is a search application where anyone can enter their github username and get back some of their github details such as repository details, stars on each repo etc. as their search result.
The application worked perfectly without writing custom service but after writing a custom service there is an error in my service which I am not able to understand. Any help will be appreciated.
Application Demo here
-
Relevant code needs to be contained in the question. Questions should be self contained and demos are secondary. That demo can change later making question useless in the future. Also people should be able to review the full issue and then decide if they want to look at democharlietfl– charlietfl2015-07-28 13:00:00 +00:00Commented Jul 28, 2015 at 13:00
-
If possible sir, please take a look at the demo once.user61092– user610922015-07-28 13:02:06 +00:00Commented Jul 28, 2015 at 13:02
-
@user61092, we shouldn't have to go off site to view the code. Demos are good (and encouraged), but all relevant code should also be in the question.Tom– Tom2015-07-28 13:03:57 +00:00Commented Jul 28, 2015 at 13:03
Add a comment
|
1 Answer
Your injection is incorrect. Since you didn't post code in the question, currently, you have:
myApp.controller("MainController", [
"$scope",
"$http",
"$log",
"$location",
"$anchorScroll",
MainController])
However, your function looks like this, meaning your github function is actually $http:
var MainController = function($scope, github, $log, $location, $anchorScroll)
Seeing that you don't use $http anywhere in your controller, I assume that this is an oversight, and you should simply replace $http with github, like:
myApp.controller("MainController", [
"$scope",
"github", // changed $http to github
"$log",
"$location",
"$anchorScroll",
MainController])
1 Comment
user61092
Thanks. It worked! Also I will take care of the guidelines and rules while posting further questions.