2

I have this factory and I have the error in the title. How can I fix this?

(function (angular,namespace) {

    var marketplace = namespace.require('private.marketplace');

    angular.factory('blueStripeViewModelFactory', [
        '$http', function blueStripeViewModelFactory($http) {
            return new BlueStripeViewModel("id", 10);
        }
    ]);

    marketplace.blueStripeViewModelFactory = blueStripeViewModelFactory;

})(window.angular,window.namespace);
2
  • 2
    Create an angular module and then create factory inside that module. Commented Dec 28, 2015 at 11:09
  • 4
    You should to use angular.module(...).factory Commented Dec 28, 2015 at 11:09

1 Answer 1

1

You can't create an independent factory as it should be created within a module.

Example,

angular.module("myFactoryModule").factory("blueStripeViewModelFactory",function(){
    // define your factory
});

Now you are able to use this factory in any of your module. To use this module, you just need to add an injector of your factory module (here, myFactoryModule).

Example,

angular.module("anotherModule", ["myFactoryModule"]);
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, this was very helpful

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.