Skip to content

Instantly share code, notes, and snippets.

Reading data before application startup in Angular 2

In this demonstration I will show you how to read data in Angular2 final release before application startup. You can use it to read configuration files like you do in other languages like Java, Python, Ruby, Php.

This is how the demonstration will load data:

a) It will read an env file named 'env.json'. This file indicates what is the current working environment. Options are: 'production' and 'development';

b) It will read a config JSON file based on what is found in env file. If env is "production", the file is 'config.production.json'. If env is "development", the file is 'config.development.json'.

@ortichon
ortichon / JSInterview_3.js
Created May 19, 2017 11:29
JavaScript Interview Question #3
for (var i = 0; i < 10; i++) {
setTimeout(function() { console.log(i); }, 100 * i);
}
@ortichon
ortichon / JSInterview_2.js
Last active May 28, 2017 09:35
JavaScript Interview Question #2
foo();
var foo = function() {
console.log(false);
}
foo();
function foo() {
console.log(true);
@ortichon
ortichon / JSInterview_1.js
Last active May 27, 2017 19:22
JavaScript Interview Question #1
var variables = { set number(value) { this._number = value; }, get number() { return Math.random(); } }
variables.number = 5;
console.log(variables.number === variables.number);