0

I am struggling to get passed the errors being caused when trying to do away with the deferredbootstrapper

Rewriting Angular.js app to do away with deferredBootstrapper

getting errors like

Uncaught Error: [$injector:modulerr] Failed to instantiate module ECP due to: Error: [$injector:unpr] Unknown provider: $http

Error: [ng:areq] Argument 'Nav' is not a function, got undefined

--- not sure how to include the previous injectorModules --- or tap into the Account and User variables to stash information before other modules are loaded

app.config(["$http", "$q", "Account", "Layout",
      function ($http, $q, Account, Layout) {

Seems like the wrong way to do it. To me it looks similar to how a directive is setup.

Community
  • 1
  • 1
The Old County
  • 89
  • 13
  • 59
  • 129
  • Am I supposed to use this injector module method before app config https://docs.angularjs.org/api/ng/function/angular.injector? – The Old County Nov 25 '14 at 13:22

1 Answers1

0

I've tried this method - but getting module timeout errors

Uncaught Error: Load timeout for modules: angular,config/component-loader,angular-translate,angular-translate-loader-static-files

define([
    "jquery",
    "angular",
    "config/component-loader"
], function ($, angular) {

    // Create a new module
    var app = angular.module("ECP", []);

    // register a new service
    app.value("ng", "ECP.services");

    // configure existing services inside initialization blocks.
    app.config(["$http, $q, Account, Layout", function($http, $q, Account, Layout) {
      // Configure existing providers

        var configObj,
            deferred;

            configObj = {
                account: null,
                layout: null
            };

            deferred = $q.defer();

            Account.fetch()
                .then(function() {
                    configObj.account = Account;
                    return Layout.fetch();
                })
                .then(function() {
                    configObj.layout = Layout;
                    return deferred.resolve(configObj);
                })
                .finally(function(){
                    return deferred.promise;
                });
    }]);

    app.init = function () {
      angular.bootstrap(document, ["ECP"]);
    };

    return app;
});
The Old County
  • 89
  • 13
  • 59
  • 129
  • Uncaught Error: [$injector:modulerr] Failed to instantiate module ECP due to: Error: [$injector:unpr] Unknown provider: $http, $q, Account, Layout – The Old County Nov 26 '14 at 11:46
  • How do I get it to accept the providers? I've been asked to hook into the Account object and hook it into the rootScope - so that is available before all other modules launch. – The Old County Nov 26 '14 at 14:00
  • 1
    Please use the edit link on your question to add additional information. The Post Answer button should be used only for complete answers to the question. – royhowie Mar 02 '15 at 02:39
  • Does anyone have an answer to the problem? – The Old County Mar 02 '15 at 14:45