Last active
November 14, 2016 04:02
-
-
Save jrwebdev/a8f39973637373e91a2cf6a2f1279ce5 to your computer and use it in GitHub Desktop.
Angular 1 vs Angular 2 ngModel
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: ` | |
| <label for="name">Your Name</label> | |
| <input id="name" name="name" ng-model="$ctrl.name" /> | |
| ` | |
| }); | |
| /***************************************************************/ | |
| // Angular 2 | |
| import {Component} from '@angular/core'; | |
| @Component({ | |
| selector: 'my-component', | |
| template: ` | |
| <label for="name">Your Name</label> | |
| <input id="name" name="name" [(ngModel)]="name" /> | |
| ` | |
| }) | |
| class MyComponent { | |
| name: string; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment