mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-11 18:32:50 +00:00
new post - also fixed loading order of posts on index page
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
app.controller('IndexController', function($scope, $http) {
|
||||
|
||||
var title = ["1-4-16", "1-1-16", "12-29-15", "12-18-15", "10-28-15", "8-13-15", "7-28-15", "7-21-15"];
|
||||
var title = ["5-22-16", "1-4-16", "1-1-16", "12-29-15", "12-18-15", "10-28-15", "8-13-15", "7-28-15", "7-21-15"];
|
||||
$scope.posts = [];
|
||||
|
||||
for (p in title) {
|
||||
@@ -9,10 +9,11 @@ app.controller('IndexController', function($scope, $http) {
|
||||
|
||||
//use anonymous function calls to pass
|
||||
//postName to the http callback function
|
||||
//pass value p to make sure $scope.posts is in order due to asynch function
|
||||
$http({
|
||||
method: 'GET',
|
||||
url: '/public/posts/' + postName + '.html'
|
||||
}).then((function(postName) {
|
||||
}).then((function(postName, p) {
|
||||
return function(response) {
|
||||
|
||||
var html = response.data;
|
||||
@@ -23,9 +24,9 @@ app.controller('IndexController', function($scope, $http) {
|
||||
partial.date = $(html).find('#date').html();
|
||||
partial.intro = $(html).find('#intro').html();
|
||||
|
||||
$scope.posts.push(partial);
|
||||
$scope.posts[p] = partial;
|
||||
}
|
||||
})(postName), function errorCallback(response) {
|
||||
})(postName, p), function errorCallback(response) {
|
||||
// called asynchronously if an error occurs
|
||||
// or server returns response with an error status.
|
||||
console.log("Error Loading Post");
|
||||
|
||||
Reference in New Issue
Block a user