lucas lucas - 3 months ago 6
AngularJS Question

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) {

...
}

})();




Answer

You have a syntax error here:

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

};

That should be:

.service('addingNewTaskService', function() {

});
Comments