main.component.js 1007 B

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. angular
  3. .module('app')
  4. .component('main', {
  5. templateUrl: '/resources/main/main.component.html',
  6. controller: ['$rootScope', '$scope', '$location', 'cms', function ($rootScope, $scope, $location, cms) {
  7. Object.assign($scope, {
  8. user: cms.user,
  9. logout: _ => {
  10. cms.Logout().then(_ => { $location.path('/signin') })
  11. }
  12. })
  13. let locker = false;
  14. const app = document.querySelector('app');
  15. app.addEventListener('scroll', e => {
  16. const position = (app.offsetHeight + app.scrollTop) >= (app.scrollHeight - 200);
  17. if (position && !locker) {
  18. locker = true;
  19. setTimeout(() => { locker = false }, 1000);
  20. $rootScope.$emit('scroll-end', {})
  21. }
  22. })
  23. }],
  24. $routeConfig: [
  25. { path: '/dashboard', name: 'Dashboard', component: 'dashboard' },
  26. { path: '/news', name: 'News', component: 'news' },
  27. { path: '/news/:id', name: 'Post', component: 'post' }
  28. ]
  29. });