Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kroid/angular-query-master
Angular module for deep parsing query uri
https://github.com/kroid/angular-query-master
Last synced: 2 months ago
JSON representation
Angular module for deep parsing query uri
- Host: GitHub
- URL: https://github.com/kroid/angular-query-master
- Owner: Kroid
- Created: 2015-03-02T18:22:01.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-03-02T21:19:33.000Z (almost 10 years ago)
- Last Synced: 2024-10-08T19:19:34.254Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 125 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# angular-query-master
Stringify and parse search query strings with nested params. Based on https://github.com/hapijs/qs nodejs package.## Motivation
$location and $routeParams not enought for deep parse query arguments:```javascript
// url: /page?users[0][id]=1&users[0][name]=Joe&users[1][id]=2&users[1][name]=Kevin$location.search()
{
"users[0][id]": "1",
"users[0][name]": "Joe",
"users[1][id]": "2",
"users[1][name]": "Kevin"
}
```## Solution
```javascript
searchParse('users[0][id]=1&users[0][name]=Joe&users[1][id]=2&users[1][name]=Kevin'){
users: [
{id: '1', name: 'Joe'},
{id: '2', name: 'Kevin'}
]
}
```## Getting started:
### Get the code:
Install via **[Bower](http://bower.io/)** `$ bower install --save angular-query-master`.Or [download the release](http://rawgit.com/kroid/angular-query-master/master/dist/angular-query-master.js) ([minified](http://rawgit.com/kroid/angular-query-master/master/dist/angular-query-master.min.js))
### Add module to your application.
#### index.html:
```html
```
#### app.js
```javascript
(function() {
angular
.module('app', ['queryMaster'])
.controller('AppController', controller);controller.$inject = ['searchParse']
function controller(searchParse) {
var parsed = searchParse(location.search.slice(1));
console.log(parsed);
}
})();
```## Documentation
coming soon