Angular 2 Cut Event

Angular 2 cut event using the EventEmitter, a mother component receives the cut event from the child component when a user cuts content.

angular 2 cut example
angular 2 cut example

Try it yourself,Live Example

try angular 2 cut event
try angular 2 cut event
/**
 * Created by Tareq Boulakjar. from angulartypescript.com
 */
import {Component,EventEmitter,Output} from 'angular2/core';

/*Child Component Will (Send or Emit) a Cut Event */
@Component({
    selector: 'event-emitter-cut-com',
    template:`
                <h2>EventEmitter on Cut</h2>
                <input type="text" value="Do Cut Action To See" (cut)="eventEmitCut($event)" class="event-emitter-cut-component-style"/>

    `,
    styles:[`
            .event-emitter-cut-component-style {
              width: 200px;
              background-color:#00AA00;
              color: white;
             }

         `]
})
class EventEmitterCutComponent {
    @Output() eventEmitterCut = new EventEmitter();

    eventEmitCut(event) {
        this.eventEmitterCut.emit(event);
    }

}
/*Mother is the receiver of the event */

@Component({
    selector: 'event-emitter-cut',
    template: `
                <event-emitter-cut-com (eventEmitterCut)="receiveEvent($event)" >
                </event-emitter-cut-com>
               `,
    directives: [EventEmitterCutComponent]

})
export class EventEmitterCutExample {
    receiveEvent(event) { console.log('Cut event from angulartypescript.com.'); console.log(event);  }
}

Our example uses Typescript as programming language.

Done !