AngularJS Service Undefined: Unknown provider: $scopeProvider <- $scope

I've started learning Angular JS and I'm having a problem with injecting a service into a controller. I'm trying to put the ThreadFactory service into ThreadController, but I'm getting an undefined error when calling it. Any advice would be great. The error I'm getting is:

Unknown provider: $scopeProvider <- $scope <- ThreadService


angular.module('threadsApp', ['ngRoute']);
    .config(function ($routeProvider, $locationProvider) {
            .when('/', {
                templateUrl: 'views/index.html',
            .when('/selected/:topicName', {
                templateUrl: 'views/threads.html',
                controller: 'ThreadController',
                redirectTo: "/"


    ["$scope", "$route", "$routeParams", "ThreadService", function ($scope, $route, $routeParams, ThreadService) {
    $scope.test = "Hello!";
    $scope.test2 = ThreadService.get();


angular.module('threadsApp').service("ThreadService", ["$scope", function ($scope) {
    return {
        get: function() {
            return "Hello";

Order of Imports

    <script src="bower_components/jquery/dist/jquery.js"></script>
    <script src="bower_components/angular/angular.js"></script>
    <script src="bower_components/angular-route/angular-route.js"></script>
    <script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
    <script src="components/app.js"></script>
    <script src="components/bodyController.js"></script>
    <script src="components/TopicController.js"></script>
    <script src="components/ThreadService.js"></script>
    <script src="components/ThreadController.js"></script>



You can't actually inject $scope into your ThreadService the way you're trying to. $scope isn't a typical service when you inject it into a controller. If you remove the $scope injection from Threadservice.js, I would bet the error will go away.

In the interest of not being redundant, a fuller explanation can be found here:

Injecting $scope into an angular service function()


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.