Matteo Scandolo | 8cc22e4 | 2016-04-12 09:00:04 -0700 | [diff] [blame] | 1 | 'use strict'; |
| 2 | |
| 3 | angular.module('xos.sampleView', [ |
| 4 | 'ngResource', |
| 5 | 'ngCookies', |
| 6 | 'ngLodash', |
| 7 | 'ui.router', |
| 8 | 'xos.helpers' |
| 9 | ]) |
| 10 | .config(($stateProvider) => { |
| 11 | $stateProvider |
| 12 | .state('user-list', { |
| 13 | url: '/', |
| 14 | template: '<users-list></users-list>' |
| 15 | }); |
| 16 | }) |
| 17 | .config(function($httpProvider){ |
| 18 | $httpProvider.interceptors.push('NoHyperlinks'); |
| 19 | }) |
| 20 | .directive('usersList', function(){ |
| 21 | return { |
| 22 | restrict: 'E', |
| 23 | scope: {}, |
| 24 | bindToController: true, |
| 25 | controllerAs: 'vm', |
| 26 | templateUrl: 'templates/users-list.tpl.html', |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 27 | controller: function(Users){ |
Matteo Scandolo | 18adcb5 | 2016-04-14 12:06:50 -0700 | [diff] [blame^] | 28 | |
| 29 | this.tableConfig = { |
| 30 | columns: [ |
| 31 | { |
| 32 | label: 'E-Mail', |
| 33 | prop: 'email' |
| 34 | }, |
| 35 | { |
| 36 | label: 'E-Mail', |
| 37 | prop: 'firstname' |
| 38 | }, |
| 39 | { |
| 40 | label: 'E-Mail', |
| 41 | prop: 'lastname' |
| 42 | } |
| 43 | ], |
| 44 | classes: 'table table-striped table-condensed' |
| 45 | }; |
| 46 | |
Matteo Scandolo | 8cc22e4 | 2016-04-12 09:00:04 -0700 | [diff] [blame] | 47 | // retrieving user list |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 48 | Users.query().$promise |
Matteo Scandolo | 8cc22e4 | 2016-04-12 09:00:04 -0700 | [diff] [blame] | 49 | .then((users) => { |
| 50 | this.users = users; |
| 51 | }) |
| 52 | .catch((e) => { |
| 53 | throw new Error(e); |
| 54 | }); |
| 55 | } |
| 56 | }; |
| 57 | }); |