import { Directive , ElementRef , Output , OnInit , HostBinding , HostListener , Optional , EventEmitter } from '@angular/core' ; import { NgForm } from '@angular/forms' ; import { ThyFormDirective } from './form.directive' ; @ Directive ( { selector : '[thyFormSubmit],[thy-form-submit]' } ) export class ThyFormSubmitDirective implements OnInit { @ Output ( ) thyFormSubmit = new EventEmitter ( ) ; constructor ( private ngForm , private thyFormDirective ) { } ngOnInit ( ) { this . thyFormDirective . onSubmitSuccess = ( $event ) => { this . thyFormSubmit . emit ( $event ) ; } ; } @ HostListener ( 'click' , [ '$event' ] ) onSubmit ( $event ) { this . thyFormDirective . submit ( $event ) ; } }