Skip to content

Commit d1b61e4

Browse files
committed
Merge pull request #7 from stanislavgeorgiev/develop
Added a Setup section in the README.md to demonstrate a "Hello World" app
2 parents 1ac7798 + e100ef7 commit d1b61e4

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,33 @@ import 'wp-api-angularjs';
3131
bower install shprink/wp-api-angularjs
3232
```
3333

34+
## Setup
35+
36+
To setup wp-api-angularjs in your app:
37+
38+
```
39+
var app = angular.module('app', ['wp-api-angularjs']);
40+
41+
app.config(function (WpApiProvider) {
42+
WpApiProvider.setBaseUrl('http://www.example.com/wp-json/');
43+
});
44+
45+
app.controller('PostsController', ['$scope', '$wpApiPosts', PostsController]);
46+
47+
function PostsController($scope, $wpApiPosts) {
48+
$scope.posts = [];
49+
50+
$wpApiPosts.getList({
51+
page: 1,
52+
per_page: 10
53+
}).then(function (posts) {
54+
$scope.posts = posts.data;
55+
});
56+
}
57+
58+
59+
```
60+
3461
## Authentication
3562

3663
This library only supports basic auth. OAuth1 not being suitable for JS clients (it would mean exposing key and password out of the open)

0 commit comments

Comments
 (0)