2016-07-25 9 views
-1

Ich habe mein Angular-Projekt auf ES6 "migriert", indem ich einfach babelify zu meinem Schluck browserify hinzufügen. Alles funktionierte gut, aber ich komme wieder vom Wochenende und etwas brach ...

Meine App jetzt beschwert sich die folgenden Möglichkeiten:

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) 
    at Error (native) 
    at http://localhost:3000/js/libs.js:136:412 
    at http://localhost:3000/js/libs.js:170:134 
    at q (http://localhost:3000/js/libs.js:137:355) 
    at g (http://localhost:3000/js/libs.js:169:222) 
    at bb (http://localhost:3000/js/libs.js:173:246) 
    at c (http://localhost:3000/js/libs.js:151:19) 
    at Object.yc [as bootstrap] (http://localhost:3000/js/libs.js:151:332) 
    at http://localhost:3000/js/app.js:745:11 
    at http://localhost:3000/js/libs.js:260:226 

Wenn Sie den Link zum Öffnen Fehler:

Failed to instantiate module ng due to: 
Error: [$injector:strictdi] http://errors.angularjs.org/1.5.5/$injector/strictdi?p0=f...) 
    at Error (native) 
    at http://localhost:3000/js/libs.js:136:412 
    at Function.bb.$$annotate (http://localhost:3000/js/libs.js:328:487) 
    at e (http://localhost:3000/js/libs.js:170:442) 
    at Object.invoke (http://localhost:3000/js/libs.js:171:163) 
    at d (http://localhost:3000/js/libs.js:169:321) 
    at http://localhost:3000/js/libs.js:169:445 
    at q (http://localhost:3000/js/libs.js:137:355) 
    at g (http://localhost:3000/js/libs.js:169:222) 
    at bb (http://localhost:3000/js/libs.js:173:246 

Bei den Fehler weiter zu öffnen:

function($provide is not using explicit annotation and cannot be invoked in strict mode 

Was ich nicht verstehe, fro m das ist dieser letzte Teil function($provider ... Das ist nicht in meinem Code, und nun ... es funktionierte, bevor die Schluckaufgabe heute erneut ausgeführt wurde.

Hier ist, wie ich meine app Bootstrap:

import appConstant from './app.constant'; 
import appConfig from './app.config'; 
import appRun from './app.run'; 
import AppComponent from './app.component'; 
import coreModule from './core/core'; 
import viewsModule from './views/views'; 
import permissionsModule from './permissions/permissions'; 
import formModules from './forms-directives/form-blocks'; 
import DAOModules from './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 from array 
    .value(); 
} 

function getRoles() { 
    const initInjector = angular.injector(['ng']); 
    const $http = initInjector.get('$http'); 

    return $http.get('some-real-here') // I removed the real url for privacy reasons 
    .then((response) => response) 
    .catch((e) => console.log('error loading userData', e)); 
} 

// create and bootstrap application 
getRoles() 
    .then((roles) => { 
    angular.module('app', requires) 
     .config(appConfig) 
     .run(appRun) 
     .constant('APP_SETTINGS', appConstant({ 
     protocol: 'https', 
     host: 'some-real-here', // I removed the real url for 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, 
    }); 
    }); 

Der Fehler ausgelöst wird, wenn angular.bootstrap(...) ausgeführt wird.

Antwort

-4

strictDi entfernen: true, wie so

angular.bootstrap(document, ['app']); 
+1

Natürlich funktioniert es ohne die strictDi Flagge ... aber strenger Modus machen erforderlich, dass der Code immer noch funktioniert, wenn minimiert, und ich mag es auf bleiben . – justinledouxweb

+0

@justinledouxweb, du hast nie erwähnt, dass du diese Codes in deiner Frage minimiert hast. –

Verwandte Themen