'use strict';

(function() {

class AdminController {
  constructor(User, Modal) {
    // Use the User $resource to fetch all users
    this.users = User.query();

    // Our callback function is called if/when the delete modal is confirmed
    this.delete = Modal.confirm.delete(user => {
      this.users.splice(this.users.indexOf(user), 1);

  .controller('AdminController', AdminController);



<div ng-include="'components/navbar/navbar.html'"></div>

<div class="container">
  <p>The delete user and user index api routes are restricted to users with the 'admin' role.</p>
  <ul class="list-group">
    <li class="list-group-item" ng-repeat="user in users">
        <span class="text-muted">{{}}</span>
        <!-- Our delete modal takes a string as the first arg (used to display what we are deleting) 
        all other args are passed to the callback defined in admin.controller.js -->
        <a ng-click="delete(, user)" class="trash"><span class="glyphicon glyphicon-trash pull-right"></span></a>

Leave a Reply