Skip to content

Instantly share code, notes, and snippets.

@sasasa671
Created January 21, 2016 03:13
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save sasasa671/0f5d816774cb3583f7e4 to your computer and use it in GitHub Desktop.
.controller('ApptsController', function($scope, $http, $state, $rootScope) {
$scope.postData = function (time, date) {
// don't use console.log, but debugger, it's much handier
console.log(" Appointment Times Listed");
$http({
method: 'GET',
url: 'https://api.parse.com/1/classes/appointments',
params: {
time: time,
date: date
},
headers: {
'X-Parse-Application-Id': 'B5o3R92gcRqOLh4fYE6r5Uz4Z0pvwzxt5iLIKBUn',
'X-Parse-REST-API-Key': '9Yu15zG7jKQ3X2eEK26kz2CsLJYvtrO8Mwnm6BbP',
}
})
.success(function (response, params, status, data, headers, config) {
console.log();
$scope.appts = response.results; // response is an object conataining the reuslt array
// w
})
.error(function (params, status) {
console.log(time + " eror");
});
};
<ion-view title="Appointments" right-buttons="rightButtons">
<ion-content has-header="true" has-tabs="true" padding="true" data-ng-init="postData()">
<ion-refresher pulling-text="Pull to refresh" on-refresh="doRefresh()">
</ion-refresher>
<div class="list">
<div class="item item-divider">
Upcoming Appointments
</div>
<a class="item" href="#" ng-repeat="item in appts">
Time: {{ item.time }} - Stylist: {{ item.stylist }}
</a>
</div>
</ion-content>
</ion-view>
@sasasa671
Copy link
Author

$scope.doRefresh = function (time, date) {
// don't use console.log, but debugger, it's much handier
console.log(" Appointment Times Listed");
$http({
method: 'GET',
url: 'https://api.parse.com/1/classes/appointments',
params: {
time: time,
date: date
},
headers: {
'X-Parse-Application-Id': 'B5o3R92gcRqOLh4fYE6r5Uz4Z0pvwzxt5iLIKBUn',
'X-Parse-REST-API-Key': '9Yu15zG7jKQ3X2eEK26kz2CsLJYvtrO8Mwnm6BbP',
}
})
.success(function (response, params, status, data, headers, config) {
console.log();
$scope.appts = response.results; // response is an object conataining the reuslt array
// w
$scope.$broadcast('scroll.refreshComplete')
})
.error(function (params, status) {
console.log(time + " eror");
});
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment