After an introduction to Angular.js at CodeSchool via FreeCodeCamp, I am coding a zipline where I have to Stylize Stories on Camper News. Basically, I am making a call to an API and need to display the result.
However, I have difficulties displaying the result of my API call with angular.js. I searched on the web and on StackOverflow and could not find a way to fix my issue.
Here is my app.js:
(function() {
var app = angular.module('camperNews', []);
app.controller('StoryController', ['$http', function($http) {
var story = this;
story.news = [];
$http.get('http://www.freecodecamp.com/news/hot').
then(function(response) {
story.news = response;
}, function(err) {
console.error('ERR', err);
});
}]);
})();
And my HTML:
<body ng-controller="StoryController as story">
<div id="container" class="text-center">
<div id="posts" class="text-center" ng-repeat="new in story.news">
<div class="post">
<div class="author">
<a href="{{new.link}}" target="_blank"><img class="author-picture" src="{{new.author.picture}}"></a>
</div>
</div>
</div>
</div>
</body>
I looked in the console and my call is returning something, the problem is obviously in my HTML and caused by my lack of experience. I would help to find a solution or hints on how to fix my issue.
Thank you in advance.
story.news=response.datain the.thenblock.