On the problem that angularjs uses routing to dynamically load pages and load JS

when using angularJs"s ngRoute to build a single-page application, because the page application wants to achieve the function of dynamic loading, configure conscientiously according to the event routing

if you directly use the configuration method of the binding module, you can obtain the corresponding page data

// create the module and name it scotchApp
var scotchApp = angular.module("scotchApp", ["ngRoute"]);

// configure our routes
scotchApp.config(function($routeProvider) {
    $routeProvider.when("/", {
        controller : "myCtrl",
        templateUrl : getUrl("wxappList"),
    });
});

scotchApp.controller("mainController", function($scope) {

});

if the naming method is in the controller, the method will not be executed

var scotchApp = angular.module("scotchApp", ["ngRoute"]);

// configure our routes


scotchApp.controller("mainController", function($scope) {
    $scope.run = function(){
        scotchApp.config(function($routeProvider) {
            $routeProvider.when("/", {
                controller : "myCtrl",
                templateUrl : getUrl("wxappList"),
            });
        });
    }

    $scope.run();
});

because more and more pages will be loaded, I want to load dynamically and load the corresponding JS file at the same time.

Jun.10,2021

our company's old projects also use AngularJS
each module to load the corresponding js and css
We are using Angular's third-party routing: ui-router
or using oclazyload can also
reference:
https://www.cnblogs.com/pengj.
https://www.cnblogs.com/jonne.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2c47d-2bb2e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2c47d-2bb2e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?