File: src/packages/common/providers/routing.js

Recommend this page to a friend!
  Classes of Alien Fernandez   Seed Sails Angular   src/packages/common/providers/routing.js   Download  
File: src/packages/common/providers/routing.js
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Seed Sails Angular
Full stack framework based on Sails, Node, Angular
Author: By
Last change: Update of src/packages/common/providers/routing.js
Date: 2 years ago
Size: 1,869 bytes
 

Contents

Class file image Download
import 'ui-router-extras'; import _ from "lodash"; import Common from './lagoProvider'; //import debug from 'debug'; function routing(module, futureRoutes) { module.requires.push('ct.ui.router.extras.future'); module.requires.push(Common.name); let RouterConfig = ["$stateProvider", "$futureStateProvider", "lagoProvider", ($stateProvider, $futureStateProvider, lagoProvider) => { $futureStateProvider.stateFactory('load', ['$q', '$ocLazyLoad', 'futureState', ($q, $ocLazyLoad, futureState) => { let def = $q.defer(); //let views = JSON.stringify(eval('(' + futureState.views + ')')); //debug(futureState.stateName); if (futureState.parent) { lagoProvider.parent(futureState.parent); } System.import(futureState.src) .then(loaded => { var newModule = loaded; if (!loaded.name) { if (!_.isEmpty(loaded.default)){ newModule = loaded.default; }else { var key = Object.keys(loaded); newModule = loaded[key[0]]; } } $ocLazyLoad.load(newModule).then(function () { def.resolve(newModule); }).catch(error => { //debug(error); def.reject(error); }); }) .catch(error => { //debug(error); def.reject(error); }); return def.promise; }]); futureRoutes.forEach(function (r) { $futureStateProvider.futureState(r); }); }]; return RouterConfig; }; export default routing;