JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js"></script>
<section id="eventi" class="section" ng-app="MeetMountApp">
<div class="container full" ng-controller="EventsCtrl">
<div id="events-list" class="col-md-7 col-sm-7 col-xs-12">
<div ng-repeat="event in events.events" class="event show-place" data-id="@{{ event.id }}" ng-mouseover="selectEvent(event)">
<a href="#" class="thumbnail col-sm-2 col-xs-3 imgLiquidFill imgLiquid">
</a>
<div class="info-event col-sm-10 col-xs-9">
<h3>
{{ event.title }}
</h3>
<p>
{{ event.description }}
</p>
</div>
</div>
<div class="clearfix"></div>
<p class="pull-left">
<button class="btn btn-info" ng-show="events.hasMore" ng-click="loadMore()">
<i class="icon-plus icon-white"></i> Show More
</button>
<span id="loading" class="loading-bar" ng-show="events.isLoading">
<span class="label label-success">Loading..</span>
</span>
</p>
</div>
<div id="events-dx" class="col-md-5 hidden-xs" ng-controller="PlaceCtrl">
<div id="cover-place">
<div id="title-place">
<h3>{{ selectedEvent.place.name }}</h3>
</div>
</div>
<p id="text-place">
{{ selectedEvent.place.text | toPlainText }}
</p>
</div>
</div>
</section>
JavaScript
var app = angular.module('MeetMountApp', ['ngResource']);
app.factory('Event', function ($resource) {
return $resource("http://demo.meetmount.com/it/eventi/getJsonEvents");
});
app.filter('toPlainText', function(){
return function(text) {
return text ? String(text).replace(/<[^>]+>/gm, '') : '';
}
});
app.filter('addFullPathToImage', function(){
return function(text) {
return "{{ asset('images/places') }}/"+text;
}
});
app.service('EventService', function (Event) {
var self = {
'selectedEvent': null,
'page': 1,
'hasMore': true,
'isLoading': false,
'events': [],
'loadEvents': function () {
if (self.hasMore && !self.isLoading) {
self.isLoading = true;
var params = {
'page': self.page,
};
Event.get(params, function (data) {
console.log(data);
angular.forEach(data.data, function (event) {
console.log('Event: ' + event);
self.events.push(new Event(event));
});
if (!data.next_page_url) {
self.hasMore = false;
}
self.isLoading = false;
});
}
},
'loadMore': function () {
if (self.hasMore && !self.isLoading) {
self.page += 1;
self.loadEvents();
}
},
'getFirst': function(){
...