angularjs - Failed to instantiate module ng due to $injector:strictdi -
i have "migrated" angular project es6 adding babelify
gulp browserify
task. working fine, though come weekend , broke...
my app complaining of following:
angular.min.js:formatted:7382 error: [$injector:modulerr] http://errors.angularjs.org/1.5.5/$injector/modulerr?p0=ng&p1=error%3a%20%5…0%20%20at%20bb%20(http%3a%2f%2flocalhost%3a3000%2fjs%2flibs.js%3a173%3a246) @ error (native) @ http://localhost:3000/js/libs.js:136:412 @ http://localhost:3000/js/libs.js:170:134 @ q (http://localhost:3000/js/libs.js:137:355) @ g (http://localhost:3000/js/libs.js:169:222) @ bb (http://localhost:3000/js/libs.js:173:246) @ c (http://localhost:3000/js/libs.js:151:19) @ object.yc [as bootstrap] (http://localhost:3000/js/libs.js:151:332) @ http://localhost:3000/js/app.js:745:11 @ http://localhost:3000/js/libs.js:260:226
when opening link error:
failed instantiate module ng due to: error: [$injector:strictdi] http://errors.angularjs.org/1.5.5/$injector/strictdi?p0=f...) @ error (native) @ http://localhost:3000/js/libs.js:136:412 @ function.bb.$$annotate (http://localhost:3000/js/libs.js:328:487) @ e (http://localhost:3000/js/libs.js:170:442) @ object.invoke (http://localhost:3000/js/libs.js:171:163) @ d (http://localhost:3000/js/libs.js:169:321) @ http://localhost:3000/js/libs.js:169:445 @ q (http://localhost:3000/js/libs.js:137:355) @ g (http://localhost:3000/js/libs.js:169:222) @ bb (http://localhost:3000/js/libs.js:173:246
when opening error further:
function($provide not using explicit annotation , cannot invoked in strict mode
what not understand last part function($provider
... not in code, , well... worked before re-running gulp task today.
here how bootstrap app:
import appconstant './app.constant'; import appconfig './app.config'; import apprun './app.run'; import appcomponent './app.component'; import coremodule './core/core'; import viewsmodule './views/views'; import permissionsmodule './permissions/permissions'; import formmodules './forms-directives/form-blocks'; import daomodules './dao/dao'; import './templates'; const requires = [ 'ngcookies', 'nglocale', 'nganimate', 'ngmessages', 'ngroute', 'ngsanitize', 'permission', 'permission.ng', 'mgcrea.ngstrap', 'ui.tinymce', 'ui.mask', 'pascalprecht.translate', 'templates', coremodule.name, viewsmodule.name, permissionsmodule.name, formmodules.name, daomodules.name, ]; // require('./templates'); // requires.push('templates'); function extractroles(userdata) { const regex = /^ind/i; return _(userdata) .map((value, prop) => { const role = regex.test(prop) && value === true ? prop.replace(/([a-z])/g, '_$1').touppercase().substr(4) : null; return role; }) .compact() // remove falsy array .value(); } function getroles() { const initinjector = angular.injector(['ng']); const $http = initinjector.get('$http'); return $http.get('some-real-here') // removed real url privacy reasons .then((response) => response) .catch((e) => console.log('error loading userdata', e)); } // create , bootstrap application getroles() .then((roles) => { angular.module('app', requires) .config(appconfig) .run(apprun) .constant('app_settings', appconstant({ protocol: 'https', host: 'some-real-here', // removed real url privacy reasons port: 3000, mock: false, })) .constant('statut_map', { nouv: '/completeoffre', comp: '/analyseroffre', accp: '/documenter', docu: '/statueroffre', appr: '/enregistreroffre', enre: '/evalueroffre', }) .value('userobj', { user: roles.data, roles: extractroles(roles.data), }) .component('app', appcomponent); angular.bootstrap(document, ['app'], { strictdi: true, }); });
the error gets triggered when angular.bootstrap(...)
gets executed.
remove strictdi:true, so
angular.bootstrap(document, ['app']);
Comments
Post a Comment