angularjs eventemitter code example

Example 1: angular event emitter

@Output() open: EventEmitter<any> = new EventEmitter();


  toggel() {
  	this.open.emit(null);
  }

Example 2: output event angular

@Component({...})
export class CounterComponent {

  @Input()
  count: number = 0;

  @Output()
  change: EventEmitter<number> = new EventEmitter<number>();

  increment() {
    this.count++;
    this.change.emit(this.count);
  }

  decrement() {
    this.count--;
    this.change.emit(this.count);
  }

  	// in parent component
	//(change)="countChange($event)"> 

}

Example 3: emitter angular

<component
  (open)="open($event)"
></component>

Tags:

Html Example