Using AngularJS in web development
$scope.fetchData = function(dateTime) {
console.log(dateTime + " fetch");
$http({
method: 'GET',
url: 'https://api.example.com/appointments',
params: {
dateTime: dateTime
},
headers: {
'X-API-Key': 'XXXXX',
'X-API-REST-Key': 'XXXXX',
}
}).success(function(response, params, status, data, headers, config) {
console.log();
$scope.appointments = data;
}).error(function(params, status) {
console.log(dateTime + " error");
});
};
Using HTML to display appointments
<ion-view title="Appointments" right-buttons="rightButtons">
<ion-content has-header="true" has-tabs="true" padding="true">
<button class="button button-light" ng-click="fetchData()"> button-light </button>
<ul>
<li ng-repeat="item in appointments"> {{ appointments.dateTime }} </li>
</ul>
</ion-content>
</ion-view>
Although the console shows that the function is successful, the data is not being displayed as a list.
The payload example for one of the appointments includes a 'time' field, but it is not being shown in the list.
{
"results": [{
"createdAt": "2015-12-30T15:03:48.511Z",
"objectId": "BjP1zZ8JqD",
"time": "12:24",
"updatedAt": "2015-12-30T15:03:48.511Z"
}]
}