Last active
November 16, 2016 05:20
-
-
Save jrwebdev/36a6723fdec089cf08add754bb9cae28 to your computer and use it in GitHub Desktop.
Angular 1 vs Angular 2 Built-in Directives
This file contains hidden or 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
| // Angular 1 | |
| const module = angular.module('myModule', []); | |
| module.component('myComponent', { | |
| template: ` | |
| <div | |
| ng-if="$ctrl.isShown" | |
| ng-click="$ctrl.onClick($event)" | |
| ng-class="{blue: $ctrl.isBlue}"> | |
| Hello World! | |
| </div> | |
| <ul> | |
| <li ng-repeat="name in $ctrl.names">{{name}}</li> | |
| </ul> | |
| ` | |
| }); | |
| /***************************************************************/ | |
| // Angular 2 | |
| import {Component} from '@angular/core'; | |
| @Component({ | |
| selector: 'my-component', | |
| template: ` | |
| <div | |
| *ngIf="isShown" | |
| (click)="onClick($event)" | |
| [ngClass]="{blue: isBlue}"> | |
| Hello World! | |
| </div> | |
| <ul> | |
| <li *ngFor="let name of names">{{name}}</li> | |
| </ul> | |
| ` | |
| }) | |
| class MyComponent {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment