http://jesusjzp.github.io/blog/2014/06/09/accordion-list-ionic/
Same like that I want accordion but by using api call.
I have two api one return clinics list and another is onclick take the clinic id and call the api and display the data to that particular id in accordion list.
But by using ng-show, I am unable to show the data.
Here is my code:
<ion-list id = "background">
<div id = "background" >
<ion-item class="item-stable item item-avatar" ng-click = "select(list.ClinicId);" ng-repeat="list in searchlist">
<img ng-src = "img/1.png"/>
<!-- -->
{{list.Name}}
<p> Address: {{list.Address.Address1}}, {{list.Address.Address2}}, {{list.Address.Postcode}}, {{list.Address.State}}, {{list.Address.Suburb}}</p>
</ion-item >
<ion-item class="item-accordion" ng-show="isSelected();" ng-repeat="available in appointments" >
{{available.Appointments.Name}} {{available.Appointments.Speciality}}
</ion-item>
</div>
</ion-list>
My controller code:
ctrl.controller('CliniclistCtrl', function($scope, $state, api, $window) {
var accessData = window.sessionStorage['Cliniclist'];
$scope.searchlist = angular.fromJson(accessData);
console.log($scope.searchlist);
var UserData = window.sessionStorage['UserData'];
$scope.UserData = angular.fromJson(UserData);
/* $scope.doctorlist = function(id) {
window.alert(id);
api.AvailableAppointments(id)
.success(function(data) {
$scope.availableappointments = data;
console.log(data);
})
.error(function(data) {
console.log(data);
});
}*/
$scope.select = function(item) {
api.AvailableAppointments(item)
.success(function(data) {
$scope.availableappointments = data;
console.log(data);
window.sessionStorage['availableappointments'] = angular.toJson(data);
var appointments = window.sessionStorage['availableappointments'];
})
.error(function(data) {
console.log(data);
});
};
$scope.isSelected = function() {
var appointments = window.sessionStorage['availableappointments'];
$scope.appointments = angular.fromJson(accessData);
return $scope.appointments;
console.log($scope.appointments);
};
//logout function....
$scope.logout = function() {
api.logout()
.success(function(data, status) {
if(status == 204) {
$state.go('home');
console.log(status);
}
sessionStorage.removeItem('UserData');
})
.error(function(data) {
console.log(data);
$window.alert("Login First");
$state.go('login');
$scope.response = data;
});
}
});
please tell me how can I show the accordion…