|
1 |
| -wp-api-angularjs |
| 1 | +wp-api-angular |
2 | 2 | ================
|
3 | 3 |
|
4 |
| -Angular2 services to consume [WP-API v2](http://v2.wp-api.org/) (< 2.5kb gziped) |
| 4 | +[](https://gitter.im/shprink/wp-api-angular?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) |
5 | 5 |
|
6 |
| -If you want to use AngularJS v1, here is the latest version: [v2.0.0-rc3](https://github.com/shprink/wp-api-angularjs/tree/v2.0.0-rc3) |
| 6 | +Angular2 services to consume [WP-API v2](http://v2.wp-api.org/) |
| 7 | + |
| 8 | +[Live Demo](https://plnkr.co/edit/hqE4bvbM6HXql5Insjx8?p=preview) |
| 9 | + |
| 10 | +If you want to use AngularJS v1, here is the latest version: [v2.0.0-rc3](https://github.com/shprink/wp-api-angular/tree/v2.0.0-rc3) |
7 | 11 |
|
8 | 12 | ## Installation
|
9 | 13 |
|
10 | 14 | ```shell
|
11 |
| -npm install wp-api-angularjs |
| 15 | +npm install wp-api-angular |
12 | 16 | ```
|
13 | 17 |
|
| 18 | +### TypeScript |
| 19 | + |
| 20 | +Nothing special if you use TS |
| 21 | + |
| 22 | +### UMD |
| 23 | + |
| 24 | +UMD files are available `wp-api-angular.umd.js` and `wp-api-angular.umd.min.js`, the [Live Demo](https://plnkr.co/edit/hqE4bvbM6HXql5Insjx8?p=preview) uses them with systemJS |
| 25 | + |
14 | 26 | ## Bootstrap
|
15 | 27 |
|
16 | 28 |
|
17 | 29 | ```js
|
18 | 30 | import {
|
19 | 31 | WPAPI_PROVIDERS,
|
20 | 32 | defaultWpApi
|
21 |
| -} from 'wp-api-angularjs'; |
| 33 | +} from 'wp-api-angular'; |
22 | 34 |
|
23 | 35 | import {App} from './app';
|
24 | 36 |
|
@@ -66,7 +78,21 @@ class RequestOptionsArgs {
|
66 | 78 | }
|
67 | 79 | ```
|
68 | 80 |
|
69 |
| -This is where you can add query string to your request or change the headers. |
| 81 | +This is where you can add query string to your request or change the headers (see below). |
| 82 | + |
| 83 | +``` |
| 84 | +import { Headers } from '@angular/http'; |
| 85 | +
|
| 86 | +const headers = new Headers({ |
| 87 | + 'Content-Type': 'application/json;charset=UTF-8', |
| 88 | + 'Access-Control-Allow-Origin': '*', |
| 89 | + 'Access-Control-Max-Age': '1728000', |
| 90 | + 'Access-Control-Allow-Headers': 'Content-Type, Content-Range, Content-Disposition, Content-Description' |
| 91 | + 'Access-Control-Allow-Methods': 'DELETE, HEAD, GET, OPTIONS, POST, PUT' |
| 92 | +}); |
| 93 | +
|
| 94 | +wpApiPosts.getList({ headers }); |
| 95 | +``` |
70 | 96 |
|
71 | 97 | ### WpApiPosts
|
72 | 98 |
|
|
0 commit comments