angular2 - gpawade/gpawade.github.io GitHub Wiki

Angular uses semantic versioning http://semver.org/

Install

$ npm install -g @angular/cli

Create new Project

$ ng new my-app

Server the application

$ ng serve --open

Template Expression

Bind
//One-way from data source to view target
Syntax : 
	{{expression}}
	[target]="expression"
	bind-target="expression"

{{name}}

<img src="{{imageurl}}">

//One-way from view target to data source

Syntax : 
	(target)="statement"
	on-target="statement"


//TwoWay Data Bind
Syntax - 
	[(target)]="expression"
	bindon-target="expression"


<input [(ngModel)]="name">
Arithmatic
{{ 1 + 2}}
Calling function
{{ getValue() }}
Class Binding
<div [ngClass] = "{special : isSpecial}"></div>

<div [class.special]="isSpecial"> </div>
Style
<button [style.color]="isSpecial ? 'red' : 'green'">
Propety
<img [src]="heroImageUrl">
<hero-detail [hero]="currentHero"></hero-detail>
<div [ngClass]="{special: isSpecial}"></div>
Event
<button (click)="onSubmit($event)">Click Me</button>
<button on-click="onSubmit()">Click Me</button>

<input [value]="currentHero.name"
   (input)="currentHero.name=$event.target.value" >

ngFor

<li *ngFor="let itm of items">

</li>

ngIf

<div *ngIf="isDisplay">

</div>	
⚠️ **GitHub.com Fallback** ⚠️