JavaScript Angular config according to environment (dev, staging, production)

It's silly, I know - every time I change environment I comment out and back my app's config factory. There must be a better way, is there?

I though of checking the URL but this seems like a bad practice. The other option I had in mind was using some sort of an gulp NPM during the build process - however development has no build process.

angular.module('myApp.services')
    .factory('GemsConfig', function () {
        return {
            //apiServer: "http://localhost:3000/v2/",
            //apiServer: "https://staging.gems.org/v2/",
            apiServer: "https://api.gems.org/v2/",
            //giphyServer: "http://api.giphy.com/v1/gifs/",
            giphyServer: "https://api.giphy.com/v1/gifs/",
            TTL: 5000,
            OS: 'web',
            version: '1.1',
            apiVer: '2.0',
            checkBalanceEveryXSeconds: 600,
            //giphyKey: 'xxx',    // testing
            giphyKey: 'xxxx'
        };

    })
Answer:1

When would I do <CustomComponent function = {this.FunctionName}/> instead of <CustomComponent function = {this.FunctionName.bind(this)}? React's documentation mentions that bind() solves ...

When would I do <CustomComponent function = {this.FunctionName}/> instead of <CustomComponent function = {this.FunctionName.bind(this)}? React's documentation mentions that bind() solves ...

  1. please simply explain

I have a small issue with a recursive .find() . when I use it to find ID === 2, it returns be the object with ID === 1 ... I have been scratching my head and I don't understand why that happens my ...

I have a small issue with a recursive .find() . when I use it to find ID === 2, it returns be the object with ID === 1 ... I have been scratching my head and I don't understand why that happens my ...

I'm learning JS/Jquery and I'm trying to make a part of a form show and hide when clicking on part of the form. I am able to open part of the form, but not to close it again. As there is no error ...

I'm learning JS/Jquery and I'm trying to make a part of a form show and hide when clicking on part of the form. I am able to open part of the form, but not to close it again. As there is no error ...

  1. show hide part of text jquery
  2. css-only hide/show part of table
  3. show hide part of div

I'm trying to correctly orient an image uploaded to a canvas from Apple devices. Here's a sample of my code to correctly orient something with EXIF orientation 6 ctx.rotate(0.5 * Math.PI); ctx....

I'm trying to correctly orient an image uploaded to a canvas from Apple devices. Here's a sample of my code to correctly orient something with EXIF orientation 6 ctx.rotate(0.5 * Math.PI); ctx....

  1. canvas rotate translate
  2. canvas rotate transform
  3. js canvas rotate translate
  4. canvas scale rotate translate
  5. html canvas translate rotate
  6. javascript canvas translate rotate