This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testFun(): void { | |
this.testPromise(identity).then(data => { | |
}).catch(function (e) { | |
console.log(e); | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.use(function (req, res, next) { | |
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:4200'); | |
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE'); | |
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type'); | |
res.setHeader('Access-Control-Allow-Credentials', true); | |
next(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name 0.0.0.0; | |
root /var/www/html/dist; | |
index index.html index.htm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Router, ActivatedRoute, Params } from '@angular/router'; | |
constructor( | |
private router: Router, | |
private route: ActivatedRoute, | |
) { } | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Observable, BehaviorSubject, ReplaySubject, pipe } from 'rxjs'; | |
import { of as observableOf } from 'rxjs'; | |
import { tap, map } from 'rxjs/operators'; | |
import { distinctUntilChanged } from 'rxjs/operators'; | |
return this.http.post(`${environment.host}${environment.loginService}`, credentials) | |
.pipe( | |
map(response => { | |
const storage = sessionStorage; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ng build --base-href /mockup/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// <input type="text" class="form-control" trim #giftName /> | |
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; | |
export class UserComponent implements OnInit { | |
userNickName: String = ''; | |
.. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ng-content select="router-outlet"></ng-content> | |
<router-outlet></router-outlet> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ngOnChanges Called after a bound input property changes | |
ngOnInit Called once the component is initialized | |
ngDoCheck Called during every change detection run | |
ngAfterContentInit Called after content (ng-content) has been projected into view | |
ngAfterContentChecked Called every time the projected content has been checked | |
ngAfterViewInit Called after the component’s view (and child views) has been initialized | |
ngAfterViewChecked Called every time the view (and child views) have been checked | |
ngOnDestroy Called once the component is about to be destroyed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The Renderer is a class that is a partial abstraction over the DOM. Using the Renderer for manipulating the DOM doesn't break server-side rendering or Web Workers (where direct access to the DOM would break). | |
ElementRef is a class that can hold a reference to a DOM element. This is again an abstraction to not break in environments where the browsers DOM isn't actually available. | |
If ElementRef is injected to a component, the injected instance is a reference to the host element of the current component. | |
There are other ways to acquire an ElementRef instance like @ViewChild(), @ViewChildren(), @ContentChild(), @ContentChildren(). In this case ElementRef is a reference to the matching element(s) in the template or children. | |
Renderer and ElementRef are not "either this or that", but instead they have to be used together to get full platform abstraction. |
OlderNewer