Angular + requirejs Chrome错误:未捕获错误:[$ injector:modulerr]无法实例化模块

时间:2015-02-11 23:47:51

标签: angularjs requirejs

经过大量的搜索,没有答案符合我的特定错误,这就是我得到的:

我有一个角度使用requirejs的应用程序,该应用程序在firefox中运行良好,但由于某些原因,chrome无法正确加载并引发错误:未捕获错误:[$ injector:modulerr]无法实例化模块投资组合由于......

我在两种浏览器中看到的唯一区别是依赖加载顺序,这是我的代码:

(function () {

    require.config(
        {
            baseUrl: "protected/js",
            paths  : {
                'jquery'          : '../../assets/js/external-libs/jquery/jquery.min.2.1.1',
                'jQueryUI'        : '../../assets/js/external-libs/jquery/jquery-ui-1.11.2.min',
                'async'           : '../../assets/js/external-libs/requirejs-plugins/async',
                'propertyParser'  : '../../assets/js/external-libs/requirejs-plugins/propertyParser',
                'text'            : '../../assets/js/external-libs/requirejs-plugins/text',
                'utils'           : '../../assets/js/utils',
                'bootstrap'       : '../../assets/js/external-libs/bootstrap/bootstrap.min',
                'ui-bootstrap'    : '../../assets/js/external-libs/plugins/ui-bootstrap',
                'underscore'      : '../../assets/js/external-libs/underscore/underscore',
                'plugins'         : '../../assets/js/external-libs/plugins',
                'angular'         : '../../assets/js/external-libs/angular/angular.1.4.0-beta.4.min'

            },
            shim   : {
                'plugins' : {
                    deps   : ['jquery'],
                    exports: 'plugins'
                },
                'jQueryUI': {
                    export: "$",
                    deps  : [
                        'jquery',
                        'plugins/jquery.backstretch.min',
                        'plugins/jquery.easypiechart',
                        'plugins/jquery.flexslider.min',
                        'plugins/jquery.masonry.min',
                        'plugins/jquery.scrollto',
                        'plugins/jquery-plugins',
                        'plugins/modernizr.min'
                    ]
                },
                'bootstrap': {
                    deps: ["jquery"]
                },
                'angular' : {
                    deps   : ["jquery", "bootstrap"],
                    exports: 'angular'
                }
            }
        }
    );

    define(
        [
            'require',
            'jquery',
            'utils',
            'angular',
            'directives/contentDirective',
            'directives/navDirective'
        ], function (require, jQuery, utils, angular, contentDirective, navDirective) {
            'use strict';


            var app = angular.module('Portfolio', []);

            app.run(['$rootScope', function ($rootScope) {
                $rootScope.utils = utils;
                $rootScope.settings = utils.storage('localSettings');
                $rootScope.scrollSpyRefresh = function () {
                    setTimeout(function () {
                        $('body').scrollspy('refresh');
                    }, 1000);
                };
            }]);

            app.factory(
                "httpPost",
                function () {
                    function transformRequest(data, getHeaders) {
                        var headers = getHeaders();
                        headers[ "Content-type" ] = "application/x-www-form-urlencoded; charset=utf-8";
                        return( serializeData(data) );
                    }

                    return( transformRequest );
                    function serializeData(data) {
                        if (!angular.isObject(data)) {
                            return( ( data == null ) ? "" : data.toString() );
                        }
                        var buffer = [];
                        for (var name in data) {
                            if (!data.hasOwnProperty(name)) {
                                continue;
                            }
                            var value = data[ name ];
                            buffer.push(
                                encodeURIComponent(name) +
                                    "=" +
                                    encodeURIComponent(( value == null ) ? "" : value)
                            );
                        }
                        var source = buffer
                                .join("&")
                                .replace(/%20/g, "+")
                            ;
                        return( source );
                    }
                }
            );

            app.directive('contentView', contentDirective);
            app.directive('nav', navDirective);

            return app;
        }
    );
})();

加载订单:

在Firefox中11个位置的角度加载和jquery首先加载,在chrome角度加载2和jquery在10个位置

0 个答案:

没有答案