Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions www/js/api_services.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ angular.module('starter.services', [])
}

Friends.all = function() {
return $http.get(apiServerUrl).then(function(response) {
console.log("Got some data");
friends = response.data;
return new Friends(response.data);
});
return $http.get(apiServerUrl)
.success(function(data) {
console.log("Success: Got some data");
friends = data;
return new Friends(data);
})
.error(function(data) {
console.log("Error: " + data);
throw new Error("Server returned an error");
});
}

Friends.getByMeetupId = function(meetupId) {
Expand Down
27 changes: 19 additions & 8 deletions www/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ angular.module('starter.controllers', ['ngStorage'])
});
})

.controller('FriendsCtrl', function($rootScope, $scope, $localStorage, $ionicLoading, Friends) {
.controller('FriendsCtrl', function($rootScope, $scope, $localStorage, $ionicLoading, Friends, $ionicViewService, $ionicPopup) {
// Make the local storage available to the view
$scope.$storage = $localStorage;

Expand All @@ -47,13 +47,24 @@ angular.module('starter.controllers', ['ngStorage'])
template: '<i class="icon ion-loading-c" style="font-size:30pt"></i>'
});

var promise = Friends.all();
promise.then(function(data) {
// Inject friends data into the root scope
$rootScope.friends = data;
// Hide the busy indicator
busy.hide();
});
var promise = Friends.all()
.then(function(data) {
// Inject friends data into the root scope
$rootScope.friends = data.data;
// Hide the busy indicator
busy.hide();
})
.catch(function(data){
// Catch an error and go to the last view
$ionicViewService.getBackView().go();
// Hide the busy indicator
busy.hide();
// Display an error popup
$ionicPopup.alert({
title: 'Error',
template: 'An error occurred while trying to retrieve the friends list.'
});
});
})

.controller('FriendDetailCtrl', function($scope, $stateParams, $localStorage, Friends) {
Expand Down
18 changes: 8 additions & 10 deletions www/templates/tabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@
-->
<ion-tabs class="tabs-icon-top">


<!-- Pets Tab -->
<ion-tab title="Members" icon="icon ion-home" href="#/tab/members">
<ion-nav-view name="tab-members"></ion-nav-view>
</ion-tab>

<!-- Adopt Tab -->
<ion-tab title="Friends" icon="icon ion-heart" href="#/tab/friends">
<!-- Friends Tab -->
<ion-tab title="Friends" icon="icon ion-android-contacts" href="#/tab/friends">
<ion-nav-view name="tab-friends"></ion-nav-view>
</ion-tab>

<!-- Members Tab -->
<ion-tab title="Members" icon="icon ion-android-friends" href="#/tab/members">
<ion-nav-view name="tab-members"></ion-nav-view>
</ion-tab>

<!-- About Tab -->
<ion-tab title="Account" icon="icon ion-gear-b" href="#/tab/account">
<!-- Account Tab -->
<ion-tab title="Account" icon="icon ion-android-mixer" href="#/tab/account">
<ion-nav-view name="tab-account"></ion-nav-view>
</ion-tab>

Expand Down