{"id":17816723,"url":"https://github.com/ryandrewjohnson/angular-editme","last_synced_at":"2025-03-18T03:31:06.019Z","repository":{"id":57178329,"uuid":"53443863","full_name":"ryandrewjohnson/angular-editme","owner":"ryandrewjohnson","description":"Edit your AngularJS forms inline ala LinkedIn profiles","archived":false,"fork":false,"pushed_at":"2017-01-28T03:48:06.000Z","size":1471,"stargazers_count":4,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-12T03:37:14.763Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://ryandrewjohnson.github.io/angular-editme/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryandrewjohnson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-08T20:44:42.000Z","updated_at":"2020-02-07T02:18:46.000Z","dependencies_parsed_at":"2022-09-14T02:31:17.925Z","dependency_job_id":null,"html_url":"https://github.com/ryandrewjohnson/angular-editme","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryandrewjohnson%2Fangular-editme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryandrewjohnson%2Fangular-editme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryandrewjohnson%2Fangular-editme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryandrewjohnson%2Fangular-editme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryandrewjohnson","download_url":"https://codeload.github.com/ryandrewjohnson/angular-editme/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243896601,"owners_count":20365401,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-27T16:39:05.484Z","updated_at":"2025-03-18T03:31:05.584Z","avatar_url":"https://github.com/ryandrewjohnson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# angular-editme\r\n\r\nConvert your AngularJS input and textarea elements to be edited inline ala [LinkedIn profiles](https://www.linkedin.com/).\r\n\r\n\r\n![alt text](https://raw.githubusercontent.com/ryandrewjohnson/angular-editme/master/demo/images/angular-editme.gif \"angular-editme demo gif\")\r\n\r\n\r\n## Demo\r\n\r\nCheck out a working example on the [demo page](http://ryandrewjohnson.github.io/angular-editme/).\r\n\r\n## Installation\r\n\r\n* `npm install angular-editme` or\r\n* `bower install angular-editme` or\r\n* `jspm install npm:angular-editme` or\r\n* Download and add to your html file\r\n\r\n## Usage\r\n\r\nAdd the `shaka-editme` module as a dependency to your Angular app's main module:\r\n\r\n##### Installed with global:\r\n\r\n```javascript\r\nangular.module('app', ['shaka-editme']);\r\n```\r\n\r\n##### Installed with npm:\r\n\r\n```javascript\r\nlet angular = require('angular');\r\nangular.module('app', [require('angular-editme')]);\r\n```\r\n\r\n##### Installed with jspm:\r\n\r\n```javascript\r\nimport editme from 'angular-editme';\r\nangular.module('app', [editme]);\r\n```\r\n\r\n\r\n#### Basic example\r\n\r\nTo convert an existing input element into an editable element wrap it with the `\u003csk-editme\u003e` directive.\r\n\r\n```html\r\n\u003cform name=\"demo\"\u003e\r\n  ...\r\n  \u003csk-editme\u003e\r\n    \u003cinput type=\"text\" name=\"location\" ng-model=\"locale\" ng-required=\"true\"\u003e\r\n  \u003c/sk-editme\u003e\r\n\r\n  \u003csk-editme\u003e\r\n    \u003ctextarea name=\"description\" ng-model=\"body\" ng-required=\"true\"\u003e\u003c/textarea\u003e\r\n  \u003c/sk-editme\u003e\r\n\u003c/form\u003e\r\n```\r\n\r\nThe `\u003csk-editme\u003e` directive has the following requirements:\r\n\r\n* It must wrap a single `\u003ctextarea\u003e` or `\u003cinput type=\"text|url|date|email|week|month|number|time\"\u003e` element.\r\n* The element wrapped element must have a valid `ng-model` attirbute.\r\n\r\n\r\n\r\n#### Handling invalid input\r\n\r\nAn editable field in edit-state will remain so until a user enters a valid value. If a user enters an invalid or empty value the field will remain in the edit-state until a valid value is entered. The validity of the field is governed by the `ngModel` validators of the wrapped element.\r\n\r\n##### Example:\r\n\r\nWill validate user has entered valid email before exiting edit-state.\r\n\r\n```html\r\n\u003csk-editme\u003e\r\n  \u003cinput type=\"email\" name=\"email\" ng-model=\"email\" ng-required=\"true\"\u003e\r\n\u003c/sk-editme\u003e\r\n```\r\n\r\nWill validate user has entered only numbers before exiting edit-state.\r\n\r\n```html\r\n\u003csk-editme\u003e\r\n  \u003cinput type=\"text\" ng-model=\"number\" name=\"number\" ng-pattern=\"/\\d+/\" /\u003e\r\n\u003c/sk-editme\u003e\r\n```\r\n\r\n\r\n\r\n#### Interacting with directive from your Controller\r\n\r\nGiven markup styled with [Bootstrap](http://getbootstrap.com/css/#forms-control-validation) we can add the `has-error` class to the `form-group` element when the edmitme directive is invalid, and then remove it when the directive is valid.\r\n\r\nindex.html\r\n```html\r\n\u003c!--\r\n  on-change - will be triggered when input loses focus and the value is both changed and valid.\r\n  on-invalid - will be triggered when input loses focus and the value is invalid\r\n--\u003e\r\n\u003cdiv ng-controller=\"DemoController as demo\"\u003e\r\n  \u003cdiv class=\"form-group\" ng-class=\"{'has-error': demo.isInvalid}\"\u003e\r\n    \u003clabel\u003eEmail\u003c/label\u003e\r\n    \u003csk-editme on-change=\"demo.onChange($value)\" on-invalid=\"demo.onInvalid($error)\"\u003e\r\n      \u003cinput type=\"email\" name=\"email\" ng-model=\"demo.email\"\u003e\r\n    \u003c/sk-editme\u003e\r\n  \u003c/div\u003e\r\n\u003c/div\u003e\r\n```\r\n\r\ndemo.controller.js\r\n```javascript\r\n.controller('DemoController', function(userService) {\r\n  let vm = this;\r\n\r\n  vm.email = 'myemail@email.com';\r\n  vm.isInvalid = false;\r\n\r\n  /**\r\n   * The value arg will be the current valid value from the input.\r\n   * (same as vm.email in this case)\r\n   */\r\n  vm.onChange = (value) =\u003e {\r\n    vm.isInvalid = false;\r\n    userService.saveEmail(value);\r\n  };\r\n\r\n  /**\r\n   * The $error arg will be the input's ngModel $error object\r\n   * See $error in https://docs.angularjs.org/api/ng/type/form.FormController\r\n   */\r\n  vm.onInvalid = ($error) =\u003e {\r\n    vm.isInvalid = true;\r\n  };\r\n})\r\n```\r\n\r\n\r\n## API\r\n\r\nAll properties are optional.\r\n\r\n```html\r\n\u003csk-editme\r\n  is-editing=\"{Boolean}\"\r\n  hide-icon=\"{Boolean}\"\r\n  on-change=\"{Expression}\"\r\n  on-invalid=\"{Expression}\"\r\n  on-state-change=\"{Expression}\"\r\n\u003e\r\n\u003c/sk-editme\u003e\r\n```\r\n\r\n| Name          | Type                 | Description  | Default     |\r\n| ------------- |:---------------------| -------------| ------------|\r\n| isEditing     | Boolean              | Can be set to true if you want to start in edit mode | false\r\n| hideIcon      | Boolean              |  Will hide pencil icon if set to true | false\r\n| onChange      | Expression(Function) | Expression will be evaluated when input loses focus and the entered value is both changed and valid. The valid value is available as $value. | –\r\n| onInvalid     | Expression(Function) | Expression will be evaluated when input loses focus and the entered value is invalid. The ngModel error is available as $error. | –\r\n| onStateChange | Expression(Function) | Expression will be evaluated when the directive changes to and from edit mode. A Boolean value $isEditing is availble to determine the current state. | –\r\n\r\n\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryandrewjohnson%2Fangular-editme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryandrewjohnson%2Fangular-editme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryandrewjohnson%2Fangular-editme/lists"}