Source: directives/scroller/scroller.js

  1. /**
  2. * @ngdoc directives
  3. * @name Scroller
  4. * @module s4c.directives.scroller.Scroller
  5. *
  6. * @description
  7. * `Scroller` Controller da funcionalidade
  8. *
  9. *
  10. */
  11. 'use strict';
  12. angular.module('s4c.directives.scroller', [])
  13. .directive('scroller', scroller).directive('horario', horarioCtrl);
  14. function scroller() {
  15. return {
  16. restrict: 'E',
  17. templateUrl: 'app/directives/scroller/scroller.html',
  18. scope: {},
  19. controller: [
  20. '$scope',
  21. '$rootScope',
  22. '$http',
  23. 'API_ENDPOINT',
  24. '$timeout',
  25. '$interval',
  26. function ($scope, $rootScope, $http, API_ENDPOINT, $timeout, $interval) {
  27. $scope.scrollers;
  28. $scope.loadScroller = function () {
  29. if (window.aberto) {
  30. $http.get(API_ENDPOINT + 'scroller/feed/').then(function (data) {
  31. $scope.scrollers = data.data;
  32. });
  33. }
  34. $timeout($scope.loadScroller, 60000);
  35. };
  36. $scope.loadScroller();
  37. }
  38. ],
  39. link: function ($scope, $elem, $attrs) {
  40. }
  41. };
  42. }
  43. /**
  44. * @method horarioCtrl
  45. * @param {*} $interval
  46. */
  47. function horarioCtrl($interval) {
  48. return {
  49. restrict: 'EA',
  50. replace: true,
  51. template: '<div>{{horario}}</div>',
  52. controller: function ($scope) {
  53. $interval(function () {
  54. $scope.horario = moment().format('HH:mm');
  55. }, 60000);
  56. },
  57. link: function () {
  58. }
  59. }
  60. }
  61. horarioCtrl.$inject = ['$interval'];