Skip to content

Commit 99883c9

Browse files
committed
adding query param to getList methods
1 parent b142f52 commit 99883c9

11 files changed

+81
-134
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,14 @@ $wpApiPosts.$get(id).then(function(post) {
4040
// Get latests posts
4141
$wpApiPosts.$getList();
4242
43-
// Get latests uncategorized posts
43+
// Get filtered posts
4444
$wpApiPosts.$getList({
45-
'category_name': 'uncategorized'
45+
"page" : 2,
46+
"filter[category_name]": "uncategorized",
47+
"filter[posts_per_page]": 5,
48+
"filter[orderby]": "date",
49+
"filter[order]": "desc",
50+
"filter[post_status]": "publish"
4651
});
4752
4853
$wpApiPosts.$get(id);

dist/wp-api-angularjs.bundle.js

Lines changed: 9 additions & 30 deletions
Large diffs are not rendered by default.

dist/wp-api-angularjs.bundle.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/wp-api-angularjs.js

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,9 @@
8989
/* 3 */
9090
/***/ function(module, exports, __webpack_require__) {
9191

92-
var helper = __webpack_require__(7);
93-
9492
module.exports = angular
9593
.module('wp-api-angularjs.services.posts', ['restangular'])
96-
.factory('$wpApiPosts', ["Restangular", function (Restangular) {
94+
.factory('$wpApiPosts', ["Restangular", function(Restangular) {
9795
var posts = Restangular.service('posts');
9896

9997
posts.$getList = getList;
@@ -102,12 +100,11 @@
102100

103101
return posts;
104102

105-
function getList(filters) {
106-
return posts.getList(helper.filterize(filters));
103+
function getList(query) {
104+
return posts.getList(query);
107105
}
108106

109107
function get(id, query) {
110-
var query = query || {};
111108
return posts.one(id).get(query);
112109
}
113110

@@ -131,12 +128,11 @@
131128

132129
return media;
133130

134-
function getList() {
135-
return media.getList();
131+
function getList(query) {
132+
return media.getList(query);
136133
}
137134

138135
function get(id, query) {
139-
var query = query || {};
140136
return media.one(id).get(query);
141137
}
142138

@@ -161,12 +157,11 @@
161157

162158
return users;
163159

164-
function getList() {
165-
return users.getList();
160+
function getList(query) {
161+
return users.getList(query);
166162
}
167163

168164
function get(id, query) {
169-
var query = query || {};
170165
return users.one(id).get(query);
171166
}
172167

@@ -195,12 +190,11 @@
195190

196191
return taxonomies;
197192

198-
function getList() {
199-
return taxonomies.getList();
193+
function getList(query) {
194+
return taxonomies.getList(query);
200195
}
201196

202197
function get(taxonomy, query) {
203-
var query = query || {};
204198
return taxonomies.one(taxonomy).get(query);
205199
}
206200

@@ -213,20 +207,5 @@
213207
}
214208
}]);
215209

216-
/***/ },
217-
/* 7 */
218-
/***/ function(module, exports, __webpack_require__) {
219-
220-
module.exports = {
221-
filterize: function (filters) {
222-
filters = filters || {}
223-
var query = {};
224-
for (var i in filters) {
225-
query['filter[' + i + ']'] = filters[i];
226-
};
227-
return query;
228-
}
229-
}
230-
231210
/***/ }
232211
/******/ ])

dist/wp-api-angularjs.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Rest/Media.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ module.exports = angular
99

1010
return media;
1111

12-
function getList() {
13-
return media.getList();
12+
function getList(query) {
13+
return media.getList(query);
1414
}
1515

1616
function get(id, query) {
17-
var query = query || {};
1817
return media.one(id).get(query);
1918
}
2019

lib/Rest/Posts.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
var helper = require("../helper.js");
2-
31
module.exports = angular
42
.module('wp-api-angularjs.services.posts', ['restangular'])
5-
.factory('$wpApiPosts', function (Restangular) {
3+
.factory('$wpApiPosts', function(Restangular) {
64
var posts = Restangular.service('posts');
75

86
posts.$getList = getList;
@@ -11,12 +9,11 @@ module.exports = angular
119

1210
return posts;
1311

14-
function getList(filters) {
15-
return posts.getList(helper.filterize(filters));
12+
function getList(query) {
13+
return posts.getList(query);
1614
}
1715

1816
function get(id, query) {
19-
var query = query || {};
2017
return posts.one(id).get(query);
2118
}
2219

lib/Rest/Taxonimies.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ module.exports = angular
1010

1111
return taxonomies;
1212

13-
function getList() {
14-
return taxonomies.getList();
13+
function getList(query) {
14+
return taxonomies.getList(query);
1515
}
1616

1717
function get(taxonomy, query) {
18-
var query = query || {};
1918
return taxonomies.one(taxonomy).get(query);
2019
}
2120

lib/Rest/Users.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ module.exports = angular
1010

1111
return users;
1212

13-
function getList() {
14-
return users.getList();
13+
function getList(query) {
14+
return users.getList(query);
1515
}
1616

1717
function get(id, query) {
18-
var query = query || {};
1918
return users.one(id).get(query);
2019
}
2120

lib/helper.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)