{"id":17419671,"url":"https://github.com/bendrucker/angular-form-state","last_synced_at":"2025-04-15T00:03:03.467Z","repository":{"id":57178432,"uuid":"20963716","full_name":"bendrucker/angular-form-state","owner":"bendrucker","description":"Smarter AngularJS forms for reacting to submission states","archived":false,"fork":false,"pushed_at":"2020-06-30T21:01:30.000Z","size":53,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T08:13:56.139Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/bendrucker.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":"2014-06-18T13:50:11.000Z","updated_at":"2020-06-30T21:01:18.000Z","dependencies_parsed_at":"2022-09-09T19:00:12.069Z","dependency_job_id":null,"html_url":"https://github.com/bendrucker/angular-form-state","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendrucker%2Fangular-form-state","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendrucker%2Fangular-form-state/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendrucker%2Fangular-form-state/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendrucker%2Fangular-form-state/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bendrucker","download_url":"https://codeload.github.com/bendrucker/angular-form-state/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248968914,"owners_count":21191162,"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-17T02:29:07.012Z","updated_at":"2025-04-15T00:03:03.402Z","avatar_url":"https://github.com/bendrucker.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"angular-form-state [![Build Status](https://travis-ci.org/bendrucker/angular-form-state.svg?branch=master)](https://travis-ci.org/bendrucker/angular-form-state)\n==================\n\nSmarter AngularJS forms for reacting to submission states\n\n## Install\n\n```bash\n# npm\n$ npm install angular-form-state\n# bower\n$ bower install angular-form-state\n```\n\n## Setup\n\n```js\n// node module exports the string 'bd.form-state' for convenience\nangular.module('myApp', [\n  require('angular-form-state')\n]);\n// otherwise, include the code first then the module name\nangular.module('myApp', [\n  'bd.form-state'\n]);\n```\n\n## API\n\n### `bdSubmit`\n\nReplace your `ngSubmit` directives with `bdSubmit`.\n\n```html\n\u003cform bd-submit=\"submitForm()\"\u003e\u003c/form\u003e\n```\n\nIn addition to standard `ngSubmit` behavior, the expression passed to `bdSubmit` can return a promise.\n\nA `submission` objection is attached to [`ngFormController`](https://docs.angularjs.org/api/ng/type/form.FormController) containing:\n* **succeeded** *boolean*: `true` if the `bdSubmit` expression returns a value or fulfilled promise\n* **failed** *boolean*: `true` if the expression returns a rejected promise\n* **error** *object*: The `Error` from a rejected promise returned by the `bdSubmit` expression. Otherwise `null`.\n* **pending** *boolean*: `true` if the expression returned a promise that is still pending (not resolved or rejected)\n* **attempted** *boolean*: `true` if submission has been attempted at least once\n* **attempts** *number*: The number of times that form submission has been attempted.\n\nForm submission can be reattempted an unlimited number of times. If you wish to prevent users from resubmitting a form that was successfully sent, for example, you should implement that yourself. Submission state (`succeeded`, `failed`, `error`, `pending`) is reset on every new submission attempt and will always reflect the active/most recent submission.\n\nWhen the `bdSubmit` expression returns a rejected promise, the error is passed to [`$exceptionHandler`](https://docs.angularjs.org/api/ng/service/$exceptionHandler) which by default logs the error using `console.error`.\n\n```js\n$scope.submit = function () {\n  // return a promise, probably from $http\n};\n```\n```html\n\u003cform bd-submit=\"submitForm()\" name=\"myForm\"\u003e\n  \u003cbutton type=\"submit\"\u003eSubmit\u003c/button\u003e\n  \u003cp ng-show=\"myForm.submission.pending\"\u003eSubmitting...\u003c/p\u003e\n  \u003cp\u003eForm submitted {{myForm.submission.attempts}} times\u003c/p\u003e\n\u003c/form\u003e\n```\n\n\u003chr\u003e\n\n### `submitButton`\n\n`submitButton` can be combined with `bdSubmit` to create a simple text button that:\n\n* Disables itself and changes its text to a customizable message while form submission is pending\n* Re-enables itself and restores its text when form submission completes (succeeds or fails)\n\n```html\n\u003cform bd-submit=\"submitForm()\" name=\"myForm\"\u003e\n  \u003cbutton submit-button pending=\"Submitting...\"\u003eSubmit\u003c/button\u003e\n\u003c/form\u003e\n```\n\nThe directive will automatically add `type=\"submit\"` to the element.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbendrucker%2Fangular-form-state","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbendrucker%2Fangular-form-state","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbendrucker%2Fangular-form-state/lists"}