1.0.52 • Published 8 years ago

angular2-click-to-edit v1.0.52

Weekly downloads
67
License
MIT
Repository
github
Last release
8 years ago

Angular 2 Click-To-Edit

##Click on a data-binding to make it an input field, and save the changes!

Examples:

Newly Added!

  • Easy permission enabling/disabling edit functionality.
  • Easy to attach Field-Validation.

This Version Has:

  • Easy to implement component to wrap your bindings.
  • onSave event that calls your own save method.
  • Nice looking css style(inspired by Jira)
  • Canceling method when choosing to cancel or when clicking outside.

Installation

    npm install angular2-click-to-edit

How To Use:

Adding package to SystemJS:

systemjs.config.js

 var map = {
	'angular2-click-to-edit': 'node_modules/angular2-click-to-edit',
	}
 var packages = {
	'angular2-click-to-edit': { main: 'index' }  
 }

Step 1:

component.ts

 // Import to the component where you want to implement the click-to-edit.
 import { NDV_DIRECTIVES } from 'angular2-click-to-edit/components';

 // Include it in the Component directives
 @Component({
 	 directives: [NDV_DIRECTIVES]
 })

Step 2:

page.html

<!- This is your uneditible regular binding: ->
<p>{{user.firstName}}</p>

<!- This is your EDITABLE binding: ->
<p><ndv-edit [title]="'firstName'" [placeholder]='user.firstName' (onSave)='yourSaveMethod($event)'></ndv-edit></p>

Important Notes!

As you can see there are few parameters passed:

  • title - this is the name of the field you want to send back to the server. i.e: "email".

  • placeholder - this is the text that will be displayed by default(before editing) so we would probably like to bind our data to it.

  • min - this one is similar to minlength(for validation) and can set the minimum requirement of chars.

  • max - this one is similar to maxlength(for validation) and can limit the number of chars.

-regex - this one is similar to pattern(for validation) and can use regular expressions.

  • permission - a simple attribute, once equal to false the edit field is changed to read-only.

  • (onSave) - this one takes the function you give it and call it when the user saved his edited info!

VERY IMPORTANT TO NOTICE

$event - is the object containing the information based on the title!!!

  • for instance: title="firstName"* then $event = { firstName: 'the user edited text' }.

Thanks

1.0.52

8 years ago

1.0.51

8 years ago

1.0.50

8 years ago

1.0.49

8 years ago

1.0.48

8 years ago

1.0.47

8 years ago

1.0.46

8 years ago

1.0.45

8 years ago

1.0.44

8 years ago

1.0.43

8 years ago

1.0.42

8 years ago

1.0.41

8 years ago

1.0.40

8 years ago

1.0.39

8 years ago

1.0.38

8 years ago

1.0.37

8 years ago

1.0.36

8 years ago

1.0.35

8 years ago

1.0.34

8 years ago

1.0.33

8 years ago

1.0.32

8 years ago

1.0.31

8 years ago

1.0.30

8 years ago

1.0.29

8 years ago

1.0.28

8 years ago

1.0.27

8 years ago

1.0.26

8 years ago

1.0.25

8 years ago

1.0.24

8 years ago

1.0.23

8 years ago

1.0.22

8 years ago

1.0.21

8 years ago

1.0.20

8 years ago

1.0.19

8 years ago

1.0.18

8 years ago

1.0.17

8 years ago

1.0.16

8 years ago

1.0.15

8 years ago

1.0.14

8 years ago

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago