1

This is my service:

    app.factory('ApiStoreService', function ($q) {

        return $q(function (resolve, reject) {

            new SwaggerApi({
                discoveryUrl: "https://apiurl",
                apiKeyName : "apiKey",
                apiKey: "xxxxxxxxx",
                success: function () {
                    resolve(this);
                }
            });
        }) 
    });

which I call this way:

ApiStoreService.then(function (store) {// do something with store}

I want to pass the hardcoded values as parameters. What's the best way to achieve this in angular?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Artur Stary
  • 724
  • 2
  • 13
  • 30

2 Answers2

1
    app.factory('ApiStoreService', function ($q) {
    return{
        DoFunction: function(value){
            return $q(function (resolve, reject) {

                new SwaggerApi({
                    discoveryUrl: "https://apiurl",
                    apiKeyName : "apiKey",
                    apiKey: "xxxxxxxxx",
                    success: function () {
                        resolve(this);
                    }
                });
            })
        }
    }
});

and use it like this:

var Obj = { name:'tim'};
ApiStoreService.DoFunction(Obj);
Dominic Scanlan
  • 1,009
  • 1
  • 6
  • 12
0

I guess Angular Constants/Value would serve the purpose and please read the below gist, https://gist.github.com/demisx/9605099

reflexdemon
  • 836
  • 8
  • 21