You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.3 KiB

7 years ago
7 years ago
  1. angular.module('app.users', ['pascalprecht.translate'])
  2. .controller('UsersCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading, $filter) {
  3. $scope.users="";
  4. $scope.users=JSON.parse(localStorage.getItem('c_users'));
  5. $scope.doRefresh = function() {
  6. /* users refresh: */
  7. $http.get(urlapi + 'users')
  8. .success(function(data, status, headers, config){
  9. console.log('data success');
  10. console.log(data); // for browser console
  11. $scope.users = data; // for UI
  12. localStorage.setItem('c_users', JSON.stringify($scope.users));
  13. $scope.$broadcast('scroll.refreshComplete');//refresher stop
  14. //set userdata
  15. $scope.userdata = $filter('filter')($scope.users, {username: $scope.storageusername}, true)[0];
  16. console.log("userdata");
  17. console.log($scope.userdata);
  18. localStorage.setItem("c_userdata", JSON.stringify($scope.userdata));
  19. })
  20. .error(function(data, status, headers,config){
  21. console.log('data error');
  22. $scope.$broadcast('scroll.refreshComplete');//refresher stop
  23. })
  24. .then(function(result){
  25. users = result.data;
  26. });
  27. };
  28. $scope.doRefresh();
  29. });