Open elenat82 opened 7 years ago
import template from './example.html'; import controller from './example.controller'; /* * example Component */ const exampleComponent = { restrict: 'E', bindings: { }, template, controller }; export default exampleComponent;` ### Here is my example.controller.js: `
/* * Example Controller file * @class */ class ExampleController { /** @ngInject */ constructor( currentUser, $state) { var self = this; } } export default ExampleController;` ### Here is my example.js: `
import angular from 'angular'; import uiRouter from 'angular-ui-router'; import exampleComponent from './example.component'; const exampleModule = angular.module('example', [ uiRouter ]) .component('example', exampleComponent) .config(($stateProvider, $urlRouterProvider) => { 'ngInject'; $urlRouterProvider.otherwise('/'); $stateProvider .state('example', { url: '/example', template: '`', data: { authorizedRoles: ['md', 'superuser'] }, resolve: { authorized: function($q, $state,$timeout, $rootScope) { if ($rootScope.userlogged == false) { $timeout(function(){ $state.go('login'); }); return $q.reject('User is not logged in, redirect to login page'); } } }); }) .name; export default exampleModule;