qontu / ngx-inline-editor

Native UI Inline-editor Angular (4.0+) component
https://qontu.github.io/ngx-inline-editor
MIT License
164 stars 90 forks source link

Get event when focus out #30

Closed apriyadarshi38 closed 7 years ago

apriyadarshi38 commented 7 years ago

can i get event when focus out from input field??????

tonivj5 commented 7 years ago

This feature will be added whit #57.

You will be able to do this:

import { Component } from '@angular/core';
import { InlineEditorComponent, InlineEvent } from 'ng2-inline-editor';

@Component({
  selector: 'app-root',
  templateUrl: '<inline-editor #editor [(ngModel)]="title" type="text" (onBlur)="save($event, editor)"></inline-editor>',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'hi';

  save(event: InlineEvent, editor: InlineEditorComponent) {
    // InlineEvent is a wrapper of {event: NativeEvent, state: State of input when it was saved}
    this.title = event.state.value;
    editor.saveAndClose({
      state: {
        value: this.title,
      }
    });
  }
}

👍

tonivj5 commented 7 years ago

This should be fixed in the last version (0.2.0-alpha.0). With the change of name, you should do an npm i @qontu/ngx-inline-editor and update your imports 👍