environments ├── environment.staging.ts
angular.json
"configurations": {
"staging": { "fileReplacements": [
<!-- attention, we have the c_highlight class --> | |
<!-- c_highlight is the selector property value of the directive --> | |
<p class="c_highlight"> | |
Some text. | |
</p> |
import { Injectable } from '@angular/core'; | |
import { HnService } from './hn.service'; | |
import { Resolve } from '@angular/router'; | |
import { ActivatedRouteSnapshot } from '@angular/router'; | |
@Injectable() | |
export class HnResolver implements Resolve<any> { | |
constructor(private hnService: HnService) {} |
Observables | |
Observables are lazy collections of multiple values over time. | |
Observables are lazy. Observables are lazy in the sense that they only execute values when something subscribes to it | |
When the data is produced by the Observable itself, we call it a cold Observable. | |
When the data is produced outside the Observable, we call it a hot Observable. | |
Cold Observables |
Observable: Subscribe to it to get the values | |
Subject: Same but you also have control of the values that you want to emit into it (can subscribe to it but also emit) | |
ReplaySubject: | |
Same as subject but will keep track of the N latest emitted values and every time you subscribe to it, | |
it'll emit those N values | |
BehaviorSubject: | |
Subject where you have to set a default value, | |
if you subscribe to it before anything has been emitted you'll get the default value |
Combination Operators | |
--------------------------------- | |
combineAll | |
combineLatest :star: | |
concat :star: | |
concatAll | |
forkJoin | |
merge :star: | |
mergeAll | |
pairwise |
//--------------- ElementRef---------------------- | |
@ViewChild('foo', {static: false}) foo: ElementRef; | |
@Component({ | |
selector: 'sample', | |
template: ` |
"configurations": { | |
"production": { ... }, | |
"staging": { | |
"fileReplacements": [ | |
{ | |
"replace": "src/environments/environment.ts", | |
"with": "src/environments/environment.staging.ts" | |
} | |
] | |
} |
environments ├── environment.staging.ts
angular.json
"configurations": {
"staging": { "fileReplacements": [
var params = { | |
a: 1, | |
b: 2, | |
c: 3 | |
}; | |
var queryString = Object.keys(params).map(key => key + '=' + params[key]).join('&'); | |
// or | |
var queryString = Object.keys(params).map(function(key) { |
/* | |
##Device = Desktops | |
##Screen = 1281px to higher resolution desktops | |
*/ | |
@media (min-width: 1281px) { | |
//CSS | |