Created
March 13, 2015 16:26
-
-
Save devinsays/67055f35170385fa4a04 to your computer and use it in GitHub Desktop.
ae-1-app.js
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
var myapp = angular.module( 'myapp', [] ); | |
// Set the configuration | |
myapp.run( ['$rootScope', function($rootScope) { | |
// Variables defined by wp_localize_script | |
$rootScope.api = aeJS.api; | |
}]); | |
// Add a controller | |
myapp.controller( 'mycontroller', ['$scope', '$http', function( $scope, $http ) { | |
// Load posts from the WordPress API | |
$http({ | |
method: 'GET', | |
url: $scope.api, | |
params: { | |
'filter[posts_per_page]' : 10 | |
}, | |
}). | |
success( function( data, status, headers, config ) { | |
console.log( $scope.api ); | |
console.log( data ); | |
$scope.posts = data; | |
}). | |
error(function(data, status, headers, config) {}); | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment