angularjs - Multi EventEmitter -
dears,
i know how can use eventemitter multiple functions
i'm having buttonframe component has 3 buttons. trigger same button function parent component, working fine 1 eventemitter how can call second , third button function ?
i have created sample in plunker https://plnkr.co/edit/kaa1j1tppkoxxlgm6wye?p=preview
-->button frame
import { component, eventemitter, oninit, input, output } '@angular/core'; @component({ selector: 'buttonframe', template: `<button (click)="ufbaclist()">account list</button> <button (click)="ufbapprove()">approve</button> <button (click)="ufbattachments()">attach</button> ` }) export class buttonframecomponent implements oninit { @output() eufbaclist: eventemitter<any> = new eventemitter(); @output() eufbapprove: eventemitter<any> = new eventemitter(); @output() eufbattachments: eventemitter<any> = new eventemitter(); constructor() { } ngoninit() { } public ufbaclist() { this.eufbaclist.emit('some value send parent'); } public ufbapprove() { this.eufbapprove.emit('some value send parent'); } public ufbattachments() { this.eufbattachments.emit('some value send parent'); } } parent -->window1 import { component, eventemitter, oninit, input, output } '@angular/core'; @component({ selector: 'window1', template: `<buttonframe (eufbaclist)="ufbaclist($event)"> </buttonframe>` }) export class window1component implements oninit { constructor() { } ngoninit() { } public ufbaclist(evt) { alert("ufbaclist 2"); } public ufbapprove(evt) { alert("ufbapprove 2"); } public ufbattachments(evt) { alert("ufbattachments 2"); } }
Comments
Post a Comment