Angular Notes
Getting Started
The Basics
Components & Data Binding
Simply put, data binding facilitates communication between a component and the DOM to keep your script and the display in synch
Angular provides four types of data binding that provide variations on the direction the data flows and whether a method is called or variable is accessed.
- Interpolation: component → DOM - Displays the value of a component member variable, e.g.
<div>{{someVar}}</div>
- Property binding: component → property of an element in the DOM
<input type="text" [value]="foobar">
- Event binding: DOM event → component
<button (click)="onClick()">Hi</button>
- The component'sonClick()
method is called - Two-way data binding: Data flows both ways.
<input type="text" [(ngModel)]="someVar">
The input and component variablesomeVar
are always the same - Syntax called banana in the box syntax_
Directives
- bbc/ngImgCrop Image Crop directive for AngularJS. Enables to crop a circle or a square out of an image.