- 1.先定义一个模块,模块依赖中要加入'ngRoute'(非必须,可在任一模块上注册路由)
var module=angular.module("uiModule",['ngRoute']);- 2.在定义的模块下调用config,参数第一个是依赖'$routeProvider',紧接着是一个函数,函数的入参是$routeProvider
- 3.函数的主体是要配置的路由
module.config(['$routeProvider', function($routeProvider) {
routeProvider.when("/a", {
templateUrl: './template/a.html'
}).otherwise({
redirectTo: '/'
});
}])注:config函数只有一个参数,参数是一个数组,数组前面的函数依次是依赖,最后一个函数用来配置路由,函数的参数是数组前几项的依赖