Last active
May 1, 2019 15:58
-
-
Save jlittlejohn/f543e19d28af5ed0e589 to your computer and use it in GitHub Desktop.
JS: Angular Factory to Get WP Posts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Credit: Montague Monro | |
// https://www.youtube.com/watch?v=3WiyGmdOjbc | |
app.factory('Posts', ['$http', function ($http) { | |
return { | |
getPosts: function () { | |
var response = $http({ | |
url: ajaxurl, | |
method: "GET", | |
params: {action: 'test_ajax'} | |
}).then(function (response) { | |
return response.data; | |
}); | |
return response; | |
} | |
} | |
}]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment