Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import {Component, Input, Output} from '@angular/core';
  2. @Component({
  3.   selector: 'my-app',
  4.   template: `
  5.     <h1>Hello {{myvar}}</h1>
  6.     <a href="#" (click)="updatemyvar()">This button will set myvar = 'tony'</a>    
  7.     <my-cmp [(myvar)]="myvar"></my-cmp>    
  8. `,
  9. })
  10. export class AppComponent  {
  11.   @Input() @Output() myvar: string = "test";
  12.   updatemyvar(){
  13.     this.myvar = "gili";
  14.   }
  15. }
  16.  
  17. import {Component, Input, Output} from '@angular/core';
  18. @Component({
  19.     selector: 'my-cmp',
  20.     template: `
  21.         <h1>{{myvar}}</h1>
  22.         <a href="#" (click)="updatemyvar()">This button will set myvar = 'tony'</a>
  23.     `,
  24. })
  25. export class MyComponent  {
  26.     @Input() @Output() myvar: string;
  27.  
  28.     updatemyvar(){
  29.         this.myvar = "tony";
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement