Thumb nails
Infinite scroll
Pull to refresh
Use Reddit API to get data
Accessible without Authentication
Supports Scrollable Data
To display some Strings
app.js
(function(){
var app = angular.module('myreddit', ['ionic']);
app.controller('RedditCtrl',function($scope){
$scope.stories = [
{
title: 'First Story'
},
{
title: 'Second Story'
},
{
title: 'Third Story'
},
];
});
index.html
<body ng-app="myreddit" ng-controller="RedditCtrl">
<ion-pane>
<ion-header-bar class="bar-stable">
<h1 class="title">My Reddit</h1>
</ion-header-bar>
<ion-content>
<div>Stories: {{stories}}</div>
<div>{{stories[0].title}}</div>
<div ng-repeat="story in stories">
{{story.title}}
</div>
</ion-content>
</ion-pane>
</body>
To get data from Reddit API
app.controller('RedditCtrl',function($http,$scope){
$scope.stories = [];
$http.get('https://www.reddit.com/r/Android/new/.json').success(function(response){
console.log(response);
});
});
To get each child's specific data and push it into Story array.
$http.get('https://www.reddit.com/r/Android/new/.json').success(function(response){
angular.forEach(response.data.children,function(child){
$scope.stories.push(child.data);
});
});
index.html
<ion-content>
<div ng-repeat="story in stories">
<a href="{{story.url}}" target="_blank">{{story.title}}</a> - {{story.domain}}
</div>
</ion-content


No comments:
Post a Comment