0.1.4 • Published 6 years ago

ng2edit v0.1.4

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

ng2edit

npm version npm An Angular library for inline editing/updating of text. For Example, you can edit some data and display on the go. Please check out the Demo

Installation

To install this library, run:

$ npm install ng2edit --save

Consuming your library

Once you have installed your library, you can import your library in any Angular application. As shown in example below:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

// Import your library
import { Ng2EditModule } from 'ng2edit';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,

    // Specify your library as an import
    Ng2EditModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Once your library is imported, you can use its components, directives and pipes in your Angular application:

<!-- You can now use your library component in app.component.html -->
<h1>
  {{title}}
</h1>
<ng2edit url="/exmaple" name="nameOfField" value="valueOfdataToBeUpdated" (onSuccess)="successFunction($event);" (onError)="errorFunction($event);"></ng2edit>

Attributes

AttributesDescription
urlurl for backend service
nameName of the field
valuevalue of the field to be updated

Events

AttributesDescription
onSucessadd method for for sucess http call
onErroradd method for for error http call

Customize

Although ng2Edit comes with bootstrap styles which makes it feel like existing bootstrap component. But if you want it to see on your own way, you can use our pre-defined classes.

ClassesDescription
ng2edit-inputclass of the input-box
ng2edit-btnclass of the button with inside of it
ng2edit-btn-saveclass of the save button
ng2edit-btn-cancelclass of the cancel button

Note: For now there are no icons used we will update soon. But we have managed to add HTML Entity. Don't worry use can use your own.

Posting data to server

The data will be posted in JSON. Please take a look at example below.

{ "nameOfField": "valueofField" }

Development

To generate all *.js, *.d.ts and *.metadata.json files:

$ npm run build

To lint all *.ts files:

$ npm run lint

Issues

If library is not able to run on your local machine please raise an issue.

Contribution

If you want to enhance the plugin or to fix any major bug, pull request are most welcome.

License

MIT © Sahil Bhattacharya