{"id":16978676,"url":"https://github.com/srph/angular-xhr","last_synced_at":"2026-05-15T01:06:49.486Z","repository":{"id":23222722,"uuid":"26580013","full_name":"srph/angular-xhr","owner":"srph","description":"[DEPRECATED] Send $http requests with directives.","archived":false,"fork":false,"pushed_at":"2015-01-12T16:23:41.000Z","size":756,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-26T18:05:59.620Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://srph.github.io/angular-xhr","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/srph.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.MD","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-11-13T09:16:27.000Z","updated_at":"2016-02-11T06:11:58.000Z","dependencies_parsed_at":"2022-08-21T21:31:50.666Z","dependency_job_id":null,"html_url":"https://github.com/srph/angular-xhr","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srph%2Fangular-xhr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srph%2Fangular-xhr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srph%2Fangular-xhr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srph%2Fangular-xhr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/srph","download_url":"https://codeload.github.com/srph/angular-xhr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244880550,"owners_count":20525511,"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-14T01:43:59.481Z","updated_at":"2025-10-28T07:20:43.692Z","avatar_url":"https://github.com/srph.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"angular-xhr\n==============\n\n[![Build Status](https://travis-ci.org/srph/angular-xhr.svg)](https://travis-ci.org/srph/angular-xhr)\n[![Bower version](https://badge.fury.io/bo/angular-srph-xhr.svg)](http://badge.fury.io/bo/angular-srph-xhr)\n[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)\n\nSend ```$http``` requests with directives.\n\n- Less lines of code for your controllers.\n- Explicitly address your requests in your templates.\n- Minus one dependency (```$http```) for your controller.\n\n### Why?\n\nThere are circumstances where a certain part of your app only has to send an ```$http``` request to an API, and repetitive ```$http``` in our controller can be tedious and unacceptable.\n\nYou can send a ```POST``` to ```api/v1/users/``` with just this code:\n\n```html\n\u003cbutton\n  srph-xhr=\"api/v1/users\"\n  request-type=\"POST\"\n  request-data=\"formData\"\u003e\n\tCreate User\n\u003c/button\u003e\n```\n\nInstead of having something the code below which is, honestly, quite tedious in some situations:\n\n```\n// user-create.controller.js\n\napp.controller('UserCreateController', function($scope, $html) {\n  $scope.request = function() {\n  \t// $http...\n  }\n});\n\n\u003c!-- user-create.html --\u003e\n\u003c!-- input.. --\u003e\n\u003cbutton type=\"button\" ng-click=\"request()\"\u003eCreate User\u003c/button\u003e\n```\n\n## Let's Get Started\n\nGetting started is very easy.\n\n### Installation\n\nAdd this library (```angular-srph-xhr.js``` or ```angular-srph-xhr.min.js```) in your project after angular, like so. It **must be** in proper order.\n\n```html\n\u003cscript src=\"/path/to/angular.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"/path/to/angular-srph-xhr.min.js\"\u003e\u003c/script\u003e\n```\n\nAngular-XHR **is** available via [Bower]!\n\n```bash\nbower install angular-srph-xhr\n```\n\nWhile it is also possible to use the one provided by CDNs.\n\n```html\n\u003cscript src=\"https://cdn.rawgit.com/srph/angular-xhr/dist/angular-srph-xhr.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"https://cdn.rawgit.com/srph/angular-xhr/dist/angular-srph-xhr.min.js\"\u003e\u003c/script\u003e\n```\n\nAdd ```srph.xhr``` in your app's ```angular.module``` dependencies\n\n```js\nangular.module('myApp', [/** other deps */, 'srph.xhr'];\n```\n\n\n### Usage\n\nCheck the [API Reference, Usage](https://srph.github.io/angular-xhr/reference.html#api-reference-directive-usage)\n\n## Important Notes\n\nI wrote this as proof-of-concept for utilizing directives to its limit, as written [here](https://medium.com/@srph/breaking-down-angularjs-to-smaller-components-f2ab70a104d0). I'd like to keep this library as simple as possible.\n\nI am *in need* of contributors (especially feat requests). I have not yet touched the other features in the ```XHR``` or ```$http``` API, so please feel free to issue a feature.\n\n### Announcements\n\n**As of 12/30/2014**, I am *technically* **stopping** continuous development of this project after the release of ```v0.3```. I'm not sure which kind of design to aim for. If you find it helpful, please feel free to issue a feature (for me to continue), to copy the idea, or to fork as you wish.\n\nAfter months of fiddling with the project, I realized that this could be paired well with [Restangular](https://github.com/mgonto/restangular), which is a great library on top of ```$http```.\n\n### Status\n\nAs of ```0.3.1```:\n\n- [x] Send requests\n- [x] Smart URLs (Removing trailing slashes)\n- [x] Base URL\n- [x] Send headers, set base headers\n- [x] \\(Pre-send phase) Action / expression to execute before running the ```$http```\n- [x] Post-action / expression to execute after the $http (final block for the promise)\n- [x] Pre-action can cancel the request fn\n- [x] Send query parameters\n- [ ] File uploads\n\nThis is an alpha release, and it is **not** recommended or suitable for production.\n\n### Name\n\nYes, this is very misleading.\n\nHowever, it was a wiser decision to spend my free time on studying (```$http```, Angular, etc..), and updating the library, instead of changing lots of parts of the docs, changing lots of links, as well as re-registering on [Bower]. Also, given the fact that this is *merely* a proof-of-concept, and currently in ```alpha```.\n\n## Docs / Examples\n\nSee the introductory docs [here](https://srph.github.io/angular-xhr), [API reference / docs](https://srph.github.io/angular-xhr/reference.html), and the demos [here](https://srph.github.io/angular-xhr/examples).\n\n## Contribution\n\nFor features or fixes, I would suggest to submit an issue first before submitting a pull request. This avoids closed pull-requests; useless work.\n\n```\n=========      ================\n| issue |  -\u003e  | pull-request |\n=========      ================\n```\n\nMake sure to check the [Developer Reference doc](//srph.github.io/angular-xhr/dev-reference.html).\n\n## Changelogs\n\nView [file](https://github.com/srph/angular-xhr/blob/master/CHANGELOG.MD).\n\n## Links / References\n\n- [Github Repository](https://github.com/srph/angular-xhr)\n- [Introduction Docs](http://srph.github.io/angular-xhr/)\n- [API Docs](http://srph.github.io/angular-xhr/reference.html)\n- [Developer Docs](http://srph.github.io/angular-xhr/dev-reference.html)\n\n## Acknowledgements\n\n**angular-xhr** © 2014+, Kier Borromeo (srph). Released under the [MIT](http://mit-license.org/) License.\u003cbr\u003e\n\n\u003e [srph.github.io](http://srph.github.io) \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e GitHub [@srph](https://github.com/srph) \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e Twitter [@_srph](https://twitter.com/_srph)\n\n[MIT]: http://mit-license.org/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrph%2Fangular-xhr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsrph%2Fangular-xhr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrph%2Fangular-xhr/lists"}