lucas
lucas

Reputation: 4685

Angular service not being passed into angular controller

Would anyone know why my service is not being passed into controller. I receive an error: Argument 'fn' is not a function.

references within my main web page:

<script src="~/js/app-categories.js"></script>
<script src="~/js/addingNewTaskService.js"></script>
<script src="~/js/addNewTaskController.js"></script>

app-categories.js:

(function () {

    "use strict";

    angular.module("app-categories", ["simpleControls", "ngRoute", "ngAnimate", "addNewTask"])
        .config(function ($routeProvider) {

            ...

        });

})();

addingNewTaskService.js:

(function () {

    "use strict";

    alert("inside service");

    angular.module("app-categories")
    .service('addingNewTaskService'), function () {

    };
})();

addNewTaskController.js:

(function () {

    "use strict";

    angular.module("app-categories")
    .controller("addNewTaskController", addNewTaskController);

    function addNewTaskController($scope, $http, addingNewTaskService) {

        ...
    }

})();

Upvotes: 0

Views: 41

Answers (1)

Pop-A-Stash
Pop-A-Stash

Reputation: 6652

You have a syntax error here:

.service('addingNewTaskService'), function () {

};

That should be:

.service('addingNewTaskService', function() {

});

Upvotes: 2

Related Questions