I have a js file to consume a webservice and here i define an array that i want to use in a ng-repeat directive. this is what i have at the moment
html
<article ng-repeat="article in scopeArticles">
<h1 class="content">content is {{article.title}} </h1>
<img src="{{article.imgSource}}" href="{{article.source}}"/>
<p>{{article.description}}</p>
</article>
js file
var articles = [];
$(document).ready(function () {
$.ajax({
url: "https://newsapi.org/v1/articles?source=google-news&sortBy=top&apiKey=001034455"
}).then(function (data) {
$.each(data.articles, function (key, value) {
articles.push({
title: value.title,
description: value.description,
source: value.url,
imgSource: value.urlToImage,
date: value.publishedAt
});
})
})
});
scopeArticlesandarticlesare different variables!$httpservice (inside a controller) instead of$.ajaxto make it look and work in a more angularjs-way.