D
D
Dmitry Arushanov2015-01-22 18:25:20
Angular
Dmitry Arushanov, 2015-01-22 18:25:20

How to implement config for AngularJs application with environment variables?

Good day to all.
Actually the whole point of the question is in the title.
How can this be implemented? So that when I run applications, or rather some kind of grunt Task, I would pull up the data for the config.
I found an example that when starting a task, we pass data through the command line as arguments, then we create a config file. And our application is already using this file.
Are there any other mechanisms for passing the config to an Angular application without a predefined config file.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-01-22
Protko @Fesor

I usually make a separate module ala "app.config" in which all the necessary parameters are set as constants. Next, we have two options:
1) just a file with a module, depending on the environment, the required file is selected during assembly
2) we generate the module during assembly by taking the parameters from the json file corresponding to the environment and saving it to a js file or using it during further assembly .. Plus this method that you can add some specific things (ip address of the machine for connecting debuggers ala weinre, etc.)
ps I recommend looking towards gulp.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question