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();
});