├── .gitignore ├── LICENSE ├── README.md ├── dist ├── src │ └── ng-auto-save.js └── typings │ └── ng-auto-save.d.ts ├── gulpfile.js ├── package.json ├── src └── ng-auto-save.ts ├── tsconfig.json ├── tslint.json ├── typings ├── angularjs │ ├── angular-animate.d.ts │ ├── angular-cookies.d.ts │ ├── angular-mocks.d.ts │ ├── angular-resource.d.ts │ ├── angular-route.d.ts │ ├── angular-sanitize.d.ts │ └── angular.d.ts └── jquery │ └── jquery.d.ts └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 18 | .grunt 19 | 20 | # node-waf configuration 21 | .lock-wscript 22 | 23 | # Compiled binary addons (http://nodejs.org/api/addons.html) 24 | build/Release 25 | 26 | # Dependency directory 27 | node_modules 28 | 29 | # Optional npm cache directory 30 | .npm 31 | 32 | # Optional REPL history 33 | .node_repl_history 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Dmitry A. Efimenko 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ng-auto-save 2 | ==================== 3 | 4 | Set of angularjs directives to save inputs' values as user types 5 | 6 | Installation: 7 | ------------- 8 | via NPM: `npm install ng-auto-save` 9 | 10 | *Reference module in your app* 11 | ```javascript 12 | angular.module('app', ['ng-auto-save']); 13 | ``` 14 | 15 | Demo: 16 | ------------- 17 | [Plunker Live Demo](https://plnkr.co/edit/XrDKGgWtUjgR2XEG28Wx?p=preview) - Exchange with the database is imitated. 18 | 19 | Example: 20 | ------------- 21 | All you have to do in the controller is to provide a function to save record. This must return a promise and it takes three arguments: 22 | * **`field`** - corresponds to the column in the table in database that will be updated 23 | * **`val`** - new value to save 24 | * **`key`** - the constraint that usually goes in the `where` clause of the sql update statement 25 | 26 | **index.js - inside Controller:** 27 | ```javascript 28 | $scope.updateField = function (field, val, key) { 29 | return $http.post('/api/article/update', { id: key, field: field, val: val }) 30 | .success(function () { 31 | articleRef[field] = $scope.article[field]; 32 | }) 33 | .error(function(error) { 34 | console.log(error); 35 | }); 36 | }; 37 | ``` 38 | 39 | **index.html:** 40 | Example uses [angular-material](https://material.angularjs.org/#/), [ng-messages](https://docs.angularjs.org/api/ngMessages/directive/ngMessages), [font-awesome](http://fortawesome.github.io/Font-Awesome/) 41 | ```html 42 |
58 | ``` 59 | **Explanation of directives used:** 60 | * **`auto-save="updateField"`** - must be applied to the `