Skip to content

Commit 1953cc7

Browse files
committed
Fix readme
1 parent abddb31 commit 1953cc7

File tree

1 file changed

+38
-30
lines changed

1 file changed

+38
-30
lines changed

README.md

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,45 @@ Angular service to get simple methods to manipulate url parts
1111
bower install yllieth/angular-url-parser --save
1212
```
1313

14-
Once the lib is downloaded,
14+
Once the lib is downloaded, add a reference in your index.html
1515

16-
1. add a reference in your index.html
16+
```
17+
<script type="application/javascript" src="../bower_components/angular-url-parser/angular-url-parser.js"></script>
18+
```
1719

18-
`<script type="application/javascript" src="../bower_components/angular-url-parser/angular-url-parser.js"></script>`
19-
20-
2. add the module in your angular application
21-
22-
```javascript
23-
angular
24-
.module('YOUR-ANGULAR-APP-NAME', [
25-
'ngUrlParser'
26-
])
27-
.controller('demoCtrl', function(urlParser) {
28-
this.parts = urlParser.parse();
29-
this.protocol = urlParser.getProtocol();
30-
this.host = urlParser.getHost();
31-
this.hostname = urlParser.getHostname();
32-
this.port = urlParser.getPort();
33-
this.route = urlParser.getRoute();
34-
this.routeAttributes = urlParser.getRouteAttributes();
35-
this.queryString = urlParser.getQuerystring();
36-
this.option = urlParser.getOption();
37-
this.hash = urlParser.getHash();
38-
})
39-
```
20+
### Rails
4021

41-
3. enjoy!
22+
In your `Gemfile`, add the following line:
23+
```ruby
24+
gem 'angular-url-parser-rails'
25+
```
26+
27+
In your `application.js`, add the following line:
28+
```
29+
//= require angular-url-parser
30+
```
4231

4332
## Usage
4433

34+
```javascript
35+
angular
36+
.module('YOUR-ANGULAR-APP-NAME', [
37+
'ngUrlParser'
38+
])
39+
.controller('demoCtrl', function(urlParser) {
40+
this.parts = urlParser.parse();
41+
this.protocol = urlParser.getProtocol();
42+
this.host = urlParser.getHost();
43+
this.hostname = urlParser.getHostname();
44+
this.port = urlParser.getPort();
45+
this.route = urlParser.getRoute();
46+
this.routeAttributes = urlParser.getRouteAttributes();
47+
this.queryString = urlParser.getQuerystring();
48+
this.option = urlParser.getOption();
49+
this.hash = urlParser.getHash();
50+
})
51+
```
52+
4553
- `getProtocol([string] url): string` : Return the protocol of the given url - Example: _"http:"_, _"https:"_, ...
4654
- `getHost([string] url): string` : Return the host of the given url (without port) - Example: _"github.com"_, _"localhost"_, ...
4755
- `getHostname([string] url): string` : Return the hostname of the given url (with port) - Example: _"github.com"_, _"localhost:3000"_, ...
@@ -57,13 +65,13 @@ Once the lib is downloaded,
5765

5866
{
5967
"protocol": "http:",
60-
"host": "localhost:3000",
68+
"host": "localhost:3000",
6169
"hostname": "localhost",
62-
"port": "3000",
63-
"pathname": "/models"
64-
"search": "?sort=asc",
70+
"port": "3000",
71+
"pathname": "/models",
72+
"search": "?sort=asc",
6573
"searchObject": { "sort": "asc" },
66-
"hash": "quantiles"
74+
"hash": "quantiles"
6775
}
6876
```
6977

0 commit comments

Comments
 (0)