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
export class TestComponent { | |
constructor(private route: ActivatedRoute, private router: Router) { } | |
ngOnInit() { | |
this.route.params.subscribe(console.log); | |
this.route.queryParams.subscribe(console.log); | |
this.route.fragment.subscribe(console.log); | |
this.route.data.subscribe(console.log); | |
this.route.url.subscribe(console.log); | |
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
export class TestComponent { | |
constructor(private renderer: Renderer2, | |
private element : ElementRef) { } | |
ngOnInit() { | |
this.clickSubscription = this.renderer.listen(this.element.nativeElement, "click", handler); | |
} | |
ngOnDestroy() { | |
this.clickSubscription.unsubscribe(); |
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
export class TestComponent { | |
constructor(private element : ElementRef) { } | |
interval: Subscription; | |
click: Subscription; | |
ngOnInit() { | |
this.intervalSubscription = Observable.interval(1000).subscribe(console.log); | |
this.clickSubscription = Observable.fromEvent(this.element.nativeElement, 'click').subscribe(console.log); |
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
export class TestComponent { | |
constructor(private store: Store) { } | |
todos: Subscription; | |
ngOnInit() { | |
this.todosSubscription = this.store.select('todos').subscribe(console.log); | |
} |
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
@Component({ | |
selector: 'test', | |
template: `<todos [todos]="todos$ | async"></todos>` | |
}) | |
export class TestComponent { | |
constructor(private store: Store) { } | |
ngOnInit() { | |
this.todos$ = this.store.select('todos'); |
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
export class TestDirective { | |
@HostListener('click') | |
onClick() { | |
.... | |
} | |
} |
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
export class TestComponent { | |
constructor(private http: Http) { } | |
ngOnInit() { | |
Observable.timer(1000).subscribe(console.log); | |
this.http.get('http://api.com').subscribe(console.log); | |
} | |
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
![]; // 'false' | |
!![]; // 'true' | |
[][[]]; // 'undefined' |
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
![][1]; // 'a' | |
!![][0]; // 't' | |
[][[]][5]; // 'i' |
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
@Component({ | |
selector: 'hello', | |
template: 'Hello!' | |
}) | |
export class HelloComponent {} |