Advertisement
Fhernd

club.component.ts

Dec 18th, 2016
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Component, EventEmitter } from '@angular/core';
  2.  
  3. @Component({
  4.     selector: 'single-component',
  5.     outputs: ['putRingOnIt'],
  6.     template: `
  7.         <button (click)="liked()">Like it?</button>
  8.     `
  9. })
  10. export class SingleComponent{
  11.     putRingOnIt: EventEmitter<string>;
  12.  
  13.     constructor() {
  14.         this.putRingOnIt = new EventEmitter();
  15.     }
  16.  
  17.     liked() : void {
  18.         this.putRingOnIt.emit("ok ok ok");
  19.     }
  20. }
  21.  
  22. @Component({
  23.     selector: 'club',
  24.     template: `
  25.         <div>
  26.             <single-component
  27.                (putRingOnIt) = "ringWasPlaced($event)"
  28.            >
  29.             </single-component>
  30.         </div>
  31.     `
  32. })
  33. export class ClubComponent{
  34.     ringWasPlaced(message: string) : void {
  35.         console.log(`Put your hands up: ${message}`);
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement