------------------------------------------------------ |
------------------------------------------------------ |
ng-class |
ngClass |
<div ng-class="{active: isActive}"> <div ng-class="{active: isActive, shazam: isImportant}"> |
<div [ngClass]="{'active': isActive}"> <div [ngClass]="{'active': isActive, 'shazam': isImportant}"> <div [class.active]="isActive"> |
ng-click |
|
<button ng-click="vm.toggleImage()"> <button ng-click="vm.toggleImage($event)"> |
<button (click)="toggleImage()"> <button (click)="toggleImage($event)"> |
ng-controller |
Component Decorator |
<div ng-controller="MovieListCtrl as vm"> |
@Component({ selector: 'app-movie-list', templateUrl: './movie-list.component.html', styleUrls: [ './movie-list.component.css' ], }) |
ng-href |
|
<a ng-href="{{ angularDocsUrl }}">Angular Docs</a> |
<a [href]="angularDocsUrl">Angular Docs</a> |
ng-if |
*ngIf |
<table ng-if="movies.length"> |
<table *ngIf="movies.length"> |
ng-model |
ngModel |
<input ng-model="vm.favoriteHero"/> |
<input [(ngModel)]="favoriteHero" /> |
ng-repeat |
*ngFor |
<tr ng-repeat="movie in vm.movies"> |
<tr *ngFor="let movie of movies"> |
ng-show |
|
<h3 ng-show="vm.favoriteHero"> Your favorite hero is: {{vm.favoriteHero}} </h3> |
<h3 [hidden]="!favoriteHero"> Your favorite hero is: {{favoriteHero}} </h3> |
ng-src |
|
<img ng-src="{{movie.imageurl}}"> |
<img [src]="movie.imageurl"> |
ng-style |
ngStyle |
<div ng-style="{color: colorPreference}"> |
<div [ngStyle]="{'color': colorPreference}"> <div [style.color]="colorPreference"> |
ng-switch |
[ngSwitch] |
<div ng-switch="vm.favoriteHero && vm.checkMovieHero(vm.favoriteHero)"> <div ng-switch-when="true"> Excellent choice! </div> <div ng-switch-when="false"> No movie, sorry! </div> <div ng-switch-default> Please enter your favorite hero. </div> </div> |
<span [ngSwitch]="favoriteHero && checkMovieHero(favoriteHero)"> <p ngSwitchCase="true"> Excellent choice! </p> <p ngSwitchCase="false"> No movie, sorry! </p> <p *ngSwitchDefault> Please enter your favorite hero. </p> </span> |