J
jts-law
Guest
Rado, I added the state change event with the resolve as follows: 'use strict'; import angular from 'angular'; import jtslib from './jtslib.module'; import jtsNavigation from './jtsNavigation.module'; import jtsDomain from './jtsDomain.module'; export default angular.module('app.extensions.module', [ 'jtslib', 'jtsNavigation', 'jtsDomain' ]) .run(['$state', '$rootScope', 'jtslibService', function($state, $rootScope, jtslibService) { $rootScope.$on('$stateChangeStart', (event, toState, toParams) => { console.log("Initializing Menus: toState.resolve.allMenus"); toState.resolve.allMenus = ['$q', ($q) => { return jtslibService.getMenus(); }]; }); }]) .name; The issue now is that I'm using the menus returned by the jtslibService in the Navigation module, and this executes before the call from the toState.resolve.allMenus block. When I comment out the code to generate the side-navigation from ttMenus and either use the default from KUIB or hard code something, I don't get the error which makes me think it's a timing issue. The error I'm getting when using ttMenus is: Uncaught Error: only one instance of babel-polyfill is allowed at Object.eval (webpack:///./~/babel-polyfill/lib/index.js?:10:9) at eval (webpack:///./~/babel-polyfill/lib/index.js?:29:30) at Object.eval (eval at globalEval (webpack:///./~/jquery/dist/jquery.js?), :1560:1) at __webpack_require__ (eval at globalEval (webpack:///./~/jquery/dist/jquery.js?), :55:30) at eval (webpack:///./src/vendor.js?:3:1) at Object.eval (eval at globalEval (webpack:///./~/jquery/dist/jquery.js?), :1310:1) at __webpack_require__ (eval at globalEval (webpack:///./~/jquery/dist/jquery.js?), :55:30) at eval (webpack:///multi_(webpack)-dev-server/client?:2:18) at Object.eval (eval at globalEval (webpack:///./~/jquery/dist/jquery.js?), :3233:1) at __webpack_require__ (eval at globalEval (webpack:///./~/jquery/dist/jquery.js?), :55:30) Followed by: TypeError: Cannot read property 'bind' of undefined at eval (index.js:92) at Scope.$emit (angular.js:18414) at createIt (kendo.angular.js:261) at createWidget (kendo.angular.js:233) at Object.link (kendo.angular.js:797) at eval (angular.js:1346) at invokeLinkFn (angular.js:10426) at nodeLinkFn (angular.js:9815) at compositeLinkFn (angular.js:9055) at nodeLinkFn (angular.js:9809) (anonymous) @ angular.js:14525 (anonymous) @ angular.js:11008 $emit @ angular.js:18416 createIt @ kendo.angular.js:261 createWidget @ kendo.angular.js:233 link @ kendo.angular.js:797 (anonymous) @ angular.js:1346 invokeLinkFn @ angular.js:10426 nodeLinkFn @ angular.js:9815 compositeLinkFn @ angular.js:9055 nodeLinkFn @ angular.js:9809 (anonymous) @ angular.js:10154 processQueue @ angular.js:16832 (anonymous) @ angular.js:16876 $digest @ angular.js:17971 (anonymous) @ angular.js:18200 completeOutstandingRequest @ angular.js:6274 (anonymous) @ angular.js:6554 setTimeout (async) Browser.self.defer @ angular.js:6552 $evalAsync @ angular.js:18198 (anonymous) @ angular.js:16704 scheduleProcessQueue @ angular.js:16876 $$resolve @ angular.js:16903 doResolve @ angular.js:16912 Promise resolved (async) $$resolve @ angular.js:16899 resolvePromise @ angular.js:16887 Deferred.resolve @ angular.js:16782 proceed @ angular-ui-router.js:480 invoke @ angular-ui-router.js:476 (anonymous) @ angular-ui-router.js:455 resolve @ angular-ui-router.js:559 (anonymous) @ angular-ui-router.js:3632 forEach @ angular.js:417 resolveViews @ angular-ui-router.js:3626 processQueue @ angular.js:16832 (anonymous) @ angular.js:16876 $digest @ angular.js:17971 $apply @ angular.js:18269 done @ angular.js:12387 completeRequest @ angular.js:12613 requestLoaded @ angular.js:12541 XMLHttpRequest.send (async) (anonymous) @ angular.js:12587 sendReq @ angular.js:12332 serverRequest @ angular.js:12084 processQueue @ angular.js:16832 (anonymous) @ angular.js:16876 $digest @ angular.js:17971 $apply @ angular.js:18269 done @ angular.js:12387 completeRequest @ angular.js:12613 requestLoaded @ angular.js:12541 XMLHttpRequest.send (async) (anonymous) @ angular.js:12587 sendReq @ angular.js:12332 serverRequest @ angular.js:12084 processQueue @ angular.js:16832 (anonymous) @ angular.js:16876 $digest @ angular.js:17971 $apply @ angular.js:18269 bootstrapApply @ angular.js:1917 invoke @ angular.js:5003 doBootstrap @ angular.js:1915 bootstrap @ angular.js:1935 angularInit @ angular.js:1820 (anonymous) @ angular.js:33367 fire @ jquery.js:3187 fireWith @ jquery.js:3317 ready @ jquery.js:3536 completed @ jquery.js:3552 Side Navigation logic: 'use strict'; import angular from 'angular'; var jtsNav = angular.module('jtsNavigation', []); jtsNav.run(['$rootScope', '$state', 'jtslibService', ($rootScope, $state, jtslibService) => { console.log('jtsNav->run() start'); let homeState = 'default.module.application.home'; let lastState; let ttMenus = []; let state = $state.get('module.default'); // Build custom Side Navigation based on users access if (state && state.views && state.views['side-navigation'] ) { console.log('jtsNav side-navigation setup: Parameters, calling getMenus()'); state.views['side-navigation'].templateUrl = ""; /* Send request to get menus */ jtslibService.getMenus().then( (res) => { ttMenus = res.ttMenus; setupSideNav(ttMenus, state); }, // getMenus() successful (res) => { console.log('side-navigation call to getMenus() failed.'); } // getMenus() failed ) // jtslibService.getMenus('All').then() } // if (state && state.views && ...) console.log('jtsNav->run() finish'); }]); export default angular.module('app.extensions.module', [ 'jtsNavigation' ]).name; // Setup side navigation html template based on ttMenus contents. // Menu format taken from app\src\scripts\common\side-navigation\index.html // ------------------------------------------------------------------------ var setupSideNav = (ttMenus, state) => { console.log('jtsNav side-navigation setup, Parameters: ' + ttMenus.length); let htmlMenu = ' '; // Parameters View htmlMenu += ' ' + ' ' + ' Parameters ' + ' '; ttMenus.forEach((menu, index) => { if (menu.module !== 'Parameters') return; htmlMenu += ' ' + ' ' + ' ' + menu.menuName + ' ' + ' ' ' '; }); htmlMenu += ' '; // System Info View htmlMenu += ' ' + ' ' + ' System Info ' + ' '; ttMenus.forEach((menu, index) => { if (menu.module !== 'System Info') return; htmlMenu += ' ' + ' ' + ' ' + menu.menuName + ' ' + ' ' ' '; }); htmlMenu += ' '; state.views['side-navigation'].template = htmlMenu; console.log('jtsNav side-navigation: template created'); }; Louis
Continue reading...
Continue reading...