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 | 8cc22e4 | 2016-04-12 09:00:04 -0700 | [diff] [blame] | 28 | // retrieving user list |
Matteo Scandolo | bd2e5cd | 2016-04-12 11:59:29 -0700 | [diff] [blame] | 29 | Users.query().$promise |
Matteo Scandolo | 8cc22e4 | 2016-04-12 09:00:04 -0700 | [diff] [blame] | 30 | .then((users) => { |
| 31 | this.users = users; |
| 32 | }) |
| 33 | .catch((e) => { |
| 34 | throw new Error(e); |
| 35 | }); |
| 36 | } |
| 37 | }; |
| 38 | }); |