I am developing a single page application which retrieves blog feeds from a website.
I got JSON using jQuery AJAX, and assigned the value to the "$scope.entries"
variable, but its not reflecting the changes in View.
Since AngularJS is a two way data binding I guess the data must be binded automatically,
Here is the code,
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-resource.min.js"></script>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script>
var myApp = angular.module("myApp", []);
myApp.controller('picCtrl', function ($scope, myservice) {
$scope.entries = [];
$scope.message = "Welcome";
myservice.jsonNews().then(loadData);
function loadData(data) {
//Data Loaded from AJAX Call
debugger;
console.log(data);
angular.forEach(data.entry, function (entryX) {
$scope.entries.push(entryX);
})
};
});
myApp.service('myservice', function ($http, $q) {
return ({
jsonNews: jsonNews
});
function jsonNews() {
var BlogFeeds = "//www.blogger.com/feeds/7833828309523986982/posts/default?start-index=0001&max-results=10&alt=json";
var request = $.ajax({ url: BlogFeeds, dataType: 'jsonp' });
return (request.then(handleSuccess));
}
function handleSuccess(response) {
return (response.feed);
}
});
</script>
</head>
<body>
<div ng-app="myApp">
<div ng-controller="picCtrl">
{{message}}
<span ng-repeat="entry in entries">
<span >
<img ng-src="{{entry.media$thumbnail.url}}" />
{{entry.title.$t}}
</span>
</span>
</div>
</div>
</body>
</html>
loadData() loads data which is loaded using Angular services. Now when I assign the data to $scope.entries variable, it is not binding automatically.
am I missing something here ?