You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30-20Lines changed: 30 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -40,9 +40,11 @@ Said that, let's go to configure the plugin and learn how to use it.
40
40
41
41
### Configuration
42
42
43
-
Once installed, you need to inject the `envServiceProvider` into your Angular App config area and then, add your environments under `domains` and `vars` objects, adding also the array of domains which belongs to each environment and also for vars.
44
-
45
-
Finally, in the same config area, you need to check in what context your application is running, by adding `envServiceProvider.check()` which will automatically set the appropriate environment based on given domains.
43
+
* Once installed, inject the `envServiceProvider` into your Angular App config area.
44
+
* Organize the environments as you wish under `domains` and `vars` objects.
45
+
* You can use wildcards (`*`) to describe your domains, i.e.: `*.domain.com`.
46
+
* As optional, you can set defaults variables under `defaults` object within `vars`, to catch not-defined variables in the environments.
47
+
* Finally, in the same config area, you will need to check in which context your application is running, by adding `envServiceProvider.check()` which will automatically set the appropriate environment based on given domains.
**For now, it's very important** to not use wildcards (`*`) or regex in your environment domains. If you want to match any subdomain (i.e `sub.domain.acme.com`), you should add the main TLD: `acme.com` or `sub.domain.acme.com` in case you want to match the exact domain.
87
-
88
-
*In the next release of this plugin you'll be able to add domains using wildcards and regex*
89
-
90
98
### Usage
91
99
92
100
In order to read the configured environment variables alongside your Angular App, you need to inject `envService` into your controllers or services:
@@ -124,19 +132,21 @@ else {
124
132
```
125
133
126
134
#### read(*string[var]*)
127
-
Returns the desired environment variable. If the argument is `all`, this method will return all variables associated to the current environment.
135
+
Returns the desired environment variable. If no argument is passed, this method will return all variables associated to the current environment.
128
136
129
137
```javascript
130
138
var apiUrl =envService.read('apiUrl'); // gets '//localhost/api'
131
139
132
-
var allVars =envService.read('all'); // gets all variables configured under the current environment
140
+
var allVars =envService.read(); // gets all variables configured under the current environment
133
141
```
134
142
143
+
If the desired variable passed as argument doesn't exists in the current environment, the plugin will check into `defaults` object.
144
+
135
145
## To-Do
136
146
137
-
* Support for adding domains with wildcards or ~~regex~~
138
-
*Comprobe Add logic to `check()`
139
-
*Testing
147
+
*~~Support for adding domains with wildcards or regex~~.
148
+
*Unit testing.
149
+
*Support for protocols.
140
150
141
151
## Support
142
152
@@ -148,7 +158,7 @@ Please feel free to contribute to the plugin with new issues, requests, unit tes
148
158
149
159
## License
150
160
151
-
Copyright 2015, [Juan Pablo Barrientos Lagos (juanpablob)](http://twitter.com/juanpablob)
161
+
Copyright 2015-2017, [Juan Pablo Barrientos Lagos (juanpablob)](http://twitter.com/juanpablob)
152
162
153
163
Licensed under [The MIT License](http://www.opensource.org/licenses/mit-license.php)<br/>
154
164
Redistributions of files must retain the above copyright notice.
0 commit comments