Angularjs 2
Références :
Base
- Angular Io
- ng-book
http://victorsavkin.com/post/118372404541/the-core-concepts-of-angular-2
- https://github.com/angular/angular/tree/master/modules/playground/src
HTTP
Architecture
Observable
- Angular 2 change detection system
- Introduction to Reactive Extensions (RxJS)
- Taking advantage of Observables in Angular 2
Routing
Notes
Angularjs 2
An Angular 2 application consists of nested components. So an Angular 2 application will always have a component tree. Let’s say for this app it looks as follows:
https://angular.io/docs/ts/latest/quickstart.html
TypeScript
Composant
Class
Interface
ngIf and ngFor are called “structural directives” because they can change the structure of portions of the DOM. In other words, they give structure to the way Angular displays content in the DOM
The ngIf directive removes/puts the HTML from/into the DOM.
Structural Directives
A Structural directive changes the DOM layout by adding and removing DOM elements.Angular removes the element from DOM, stops change detection for the associated component, detaches it from DOM events (the attachments that it made) and destroys the component. The component can be garbage-collected (we hope) and free up memory.
Components often have child components which themselves have children. All of them are destroyed when ngIf destroys the common ancestor. This cleanup effort is usually a good thing.
Template Syntax
return this.jsonp
.get(‘http://en.wikipedia.org/w/api.php?callback=JSONP_CALLBACK', { search })
.map((response) => response.json()[1]);
this.items = this.term.valueChanges
.debounceTime(400)
.distinctUntilChanged()
.switchMap(term => this.wikipediaService.search(term));
The map operator expects a function that takes a value T and returns a value U
you get from an Observable
to avoid Observable<Observable<Array
The switchMap operator is comparable to flatMap in a way. Both operators automatically subscribe to the Observable that the function produces and flatten the result for us. The difference is that the switchMap operator automatically unsubscribes from previous subscriptions as soon as the outer Observable emits new values.
Reactive Extensions for JavaScript (RxJS)
reactive streams library that allows you to work with asynchronous data streams. RxJS can be used both in the browser or in the server-side using Node.js.
In RxJS, you represent asynchronous data streams using observable sequences or also just called observables.
Observable
An Observable is a collection that arrives over time. Observables can be used to model events, asynchronous requests, and animations. Observables can also be transformed, combined, and consumed using the Array methods
Observables = Promises + Events (in a way!)
https://egghead.io/lessons/javascript-introducing-the-observable
A voir :
- Form, ngFormControl, Control from angular2/common