[$controller:ctrlreg] routing using angularjs and ocLazyLoad cause problems with undefined controllers

The total control file app.js
is defined under the

root directory, and then the controller files used for the page are defined under subfolders of different directories, such as product.js, etc.
the code declared in app.js is roughly as follows (excerpt)

var sdWan = angular.module("sdWan", ["ngResource", "ngRoute", "oc.lazyLoad"])
    .config(function ($resourceProvider) {
        $resourceProvider.defaults.stripTrailingSlashes = false;
    })
    .config(["$routeProvider", "$locationProvider", function ($routeProvider, $locationProvider) {
        $routeProvider
            .when("/", {
                templateUrl: "pages/home.html",
                controller: "homeCtrl",
                resolve: {
                    deps: ["$ocLazyLoad",
                        function ($ocLazyLoad) {
                            return $ocLazyLoad.load({
                                files: [
                                    "pages/home.js"
                                ]
                            });
                        }
                    ]
                }
            })
            .when("/devicesManage/deviceList", {
                templateUrl: "pages/devicesManage/deviceList/deviceList.html",
                controller: "devCtrl",
                resolve: {
                    deps: ["$ocLazyLoad",
                        function ($ocLazyLoad) {
                            return $ocLazyLoad.load({
                                files: [
                                    "pages/devicesManage/deviceList/deviceList.js"
                                ]
                            });
                        }
                    ]
                }
            })

            .otherwise({
                redirectTo: "/"
            })
    }]);

as shown in the code, different pages have different controller, and ng-controller= "name" is added to the corresponding page.
and in the js introduced on the corresponding page, the controller, is defined as shown in the following code (pages/home.js):

sdWan.controller("homeCtrl", function ($scope) {})  // 
console.log(sdWan)  // 

and these JS are indeed loaded into the document, but the code in the controller cannot be executed, and will report
[$controller:ctrlreg] The controller with the name "homeCtrl" is not registered.
the sdWan can be obtained by console.log (sdWan) under this file. But there is a problem with defining controller.

what should I do about it?
Thank you.

Mar.14,2021

return $ocLazyLoad.load ({

)
name:"APP" ,
files: [
    'pages/home.js'
]

});
/ / add the name of your main application module before your files


encounters the same problem, except that routing is implemented using ui-router, but there is no error with the replacement of the ui-router version of the js file.

Menu