Reputation: 8960
I have a service with a few methods:
function userService($http, API, auth) {
....
}
and then used in my module like:
var app = angular.module('app', ['ngRoute'])
.service('user', userService)
...
All of this is in my app.js file, I want to separate things so its easier to maintain. I'm trying to use the line .service('user', '/services/userService')
but its not working any ideas how to i need to reference this?
Thanks.
Upvotes: 0
Views: 47
Reputation: 13167
I think you are creating a new module instead of use yours.
To retrieve an existing module and use it in a separated file, you have to do :
var app = angular.module('app')
.service('user', userService')
// ...
Instead of
var app = angular.module('app', ['ngRoute'])
.service('user', userService')
// ...
Documentation available at https://docs.angularjs.org/guide/module#creation-versus-retrieval
EDIT from @koox00 answer
Don't forgot to load all files related to your module in your markup, in the good order (before load the file containing your module declaration).
Upvotes: 1