DigitMagazine

Two Way data binding and event observation

Dec 17th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. import {Component} from 'angular2/core'
  2. selector: 'sample',
  3. providers: [],
  4. template:
  5. First Name:<input [(ngModel)]="FirstN"/>
  6. <br/>
  7. Last Name:<input [(ngModel)]="LastN"/>
  8. <br/>
  9. <br/>
  10. Value:{{FirstN} {LastN}}
  11. <br/>
  12. <br/>
  13. <button (click)="setName()">set name</button>,
  14. directives: []
  15. })
  16.  
  17. export class App {
  18. FirstN:string;
  19. LastN:string;
  20.  
  21. constructor() {
  22. this.FirstN = 'Ron';
  23. this.LastN = 'Methew';
  24.  
  25. }
  26.  
  27. setName() {
  28.  
  29. this.FirstN = 'Michael';
  30. this.LastN = 'Elango';
  31. }
  32. }
Add Comment
Please, Sign In to add comment