DaftMonk/fullstack-demo

View on GitHub
client/app/admin/admin.controller.js

Summary

Maintainability
A
0 mins
Test Coverage
'use strict';

angular.module('demoApp')
  .controller('AdminCtrl', function ($scope, $http, Auth, User) {

    // Use the User $resource to fetch all users
    $scope.users = User.query();

    $scope.delete = function(user) {
      User.remove({ id: user._id });
      angular.forEach($scope.users, function(u, i) {
        if (u === user) {
          $scope.users.splice(i, 1);
        }
      });
    };
  });