1.0.52 • Published 9 years ago

angular2-click-to-edit v1.0.52

Weekly downloads
67
License
MIT
Repository
github
Last release
9 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

9 years ago

1.0.51

9 years ago

1.0.50

9 years ago

1.0.49

9 years ago

1.0.48

9 years ago

1.0.47

9 years ago

1.0.46

9 years ago

1.0.45

9 years ago

1.0.44

9 years ago

1.0.43

9 years ago

1.0.42

9 years ago

1.0.41

9 years ago

1.0.40

9 years ago

1.0.39

9 years ago

1.0.38

9 years ago

1.0.37

9 years ago

1.0.36

9 years ago

1.0.35

9 years ago

1.0.34

9 years ago

1.0.33

9 years ago

1.0.32

9 years ago

1.0.31

9 years ago

1.0.30

9 years ago

1.0.29

9 years ago

1.0.28

9 years ago

1.0.27

9 years ago

1.0.26

9 years ago

1.0.25

9 years ago

1.0.24

9 years ago

1.0.23

9 years ago

1.0.22

9 years ago

1.0.21

9 years ago

1.0.20

9 years ago

1.0.19

9 years ago

1.0.18

9 years ago

1.0.17

9 years ago

1.0.16

9 years ago

1.0.15

9 years ago

1.0.14

9 years ago

1.0.13

9 years ago

1.0.12

9 years ago

1.0.11

9 years ago

1.0.10

9 years ago

1.0.9

9 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago