(function() {
	'use strict';

	window.app.directive('userList', function () {
		return {
			scope: { "users": "=" },
			templateUrl: '/user/template/userList.tmpl.cshtml',
			controller: controller,
			controllerAs: 'vm'
		}
	});

	controller.$inject = ['$scope', '$uibModal'];
	function controller($scope, $uibModal) {
		var vm = this;

		vm.users = $scope.users;
		vm.edit = edit;

		function edit(user) {
			$uibModal.open({
				template: '<user-edit user="user" />',
				scope: angular.extend($scope.$new(true), { user: user })
			});
		}
	}
})();