AngularJs 中的延迟加载

问题描述 投票:0回答:1

在 AngularJs 中延迟加载的最佳方法是什么?在一个与我公司相关的大项目中,我使用了不同的方法,但都不起作用。请介绍一下最简单的方法。 有一些方法,例如: oclazyloading、webpack.parcel 和......

我的代码示例不起作用: “require”与我的项目的功能显然有冲突

    .when('/chakadChequeBookRequest', {
        title: 'chakadChequeBookRequest',
        templateUrl: root + '/partials/chakadChequeBookRequest.html',
        controller: 'chakadChequeBookRequestController',
        // caseInsensitiveMatch: true,
        resolve: {
            loadModule: ['$ocLazyLoad', '$q', function ($ocLazyLoad, $q) {
                debugger;
                alert('test');
                let deferred = $q.defer();

                // After loading the controller file we need to inject the module
                // to the parent module
                require(['chakadChequeBookRequestController'], function () {
                    //     // Using OcLazyLoad we can inject the any module to the parent module
                    $ocLazyLoad.inject('chakadChequeBookRequestService');//service
                    $ocLazyLoad.inject('chakadChequeBookRequestModel');
                    deferred.resolve();
                });

                return deferred.promise;
            }]

}

angularjs requirejs
1个回答
0
投票

我在 angularJs 中的 app.js 中使用定义关键字,如下所示:

define(['require'], 函数 (require) { ………… ………… } 我添加 require.js 并包含在 html 文件中,然后加载此文件(require.js) 但我收到此错误:

定义未定义

我附上了错误图片... 请告诉我这个问题的原因。 谢谢你。

© www.soinside.com 2019 - 2024. All rights reserved.