angular.module('push') .controller('chitchatCtrl', function ($scope,CommentService,$stateParams,UserService,$ionicPopup,AccountService) { $scope.rewardHollList = [ {title: '接收信息', selected: true, type: 0}, {title: '发送信息', selected: false, type: 1}, ] $scope.changeSelected = function (index) { angular.forEach($scope.rewardHollList, function (val) { val.selected = false; }) $scope.rewardHollList[index].selected = true; list( $scope.rewardHollList[index].type) } list(0) function list(type){ CommentService.getchatlist({userId:UserService.id,isSend:type}).then((res)=>{ console.log(res) if(res.code==3350){ $scope.Listdata=res.data }else { $ionicPopup.alert({ title: '提示', template: res.message }); } }).catch(function () { $ionicPopup.alert({ title: '提示', template: "服务器错误" }); }) } })