重写 Angular 初始化



我正在努力通过尝试取消延迟引导程序时引起的错误

重写 Angular.js 应用程序以取消 deferredBootstrapper

收到类似错误

未捕获错误: [$injector:modulerr] 由于以下原因无法实例化模块 ECP: 错误: [$injector:unpr] 未知提供程序: $http

错误:[ng:areq] 参数"Nav"不是函数,未定义

---不确定如何包含以前的喷油器模块---或点击帐户和用户变量以在加载其他模块之前存储信息

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

似乎是错误的做法。对我来说,它看起来类似于指令的设置方式。

我已经尝试过这种方法 - 但出现模块超时错误

未捕获的错误:模块的加载超时:角度,配置/组件加载器,角度转换,角度转换加载器静态文件

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;
});

最新更新