lazy loading in angularJs

21 Views Asked by At

what is the best way to lazy loading in angularJs. in a big project related to my company, I used different methods, but none of them work. Please introduce me the easiest method. there is ways for example: oclazyloading, webpack.parcel and.....

sample of my code that is don't work : 'require' has conflict with functions my projects Apparently

    .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;
            }]

}

0

There are 0 best solutions below