0

I have a couple of simple resources in my resources module:

// resources/ResourceOnejs
angular.module('myApp.resources', []).factory('ResourceOne', function($resource) {
    return $resource(...);
});

// resources/ResourceTwo.js
angular.module('myApp.resources', []).factory('ResourceTwo', function($resource) {
    return $resource(...);
});

It seems like there can be only one of them used at a time.

i.e.

If I add ResourceTwo then "Unknown Provider" error when I try to inject ResourceOne, but once I remove ResourceTwo I am now able to inject ResourceTwo. Any help would be appreciated!

1 Answer 1

1

You are redeclaring the module with your syntax. Use this way

// resources/ResourceOnejs
angular.module('myApp.resources', []).factory('ResourceOne', function($resource) {
    return $resource(...);
});

// resources/ResourceTwo.js
angular.module('myApp.resources').factory('ResourceTwo', function($resource) {
    return $resource(...);
});

basically

angular.module('name',[]) //creates a new module
angular.module('name')  //gets the existing module
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.