$routeProvider.when(url, {
template: string,
templateUrl: string,
controller: string, function 或 array,
controllerAs: string,
redirectTo: string, function,
resolve: object<key, function>
③controller:
function、string或数组类型,在当前模板上执行的controller函数,生成新的scope。
④controllerAs:
string类型,为controller指定别名。
⑤redirectTo:
重定向的地址。
⑥resolve:
指定当前controller所依赖的其他模块。
template: string,
templateUrl: string,
controller: string, function 或 array,
controllerAs: string,
redirectTo: string, function,
resolve: object<key, function>
});
参数说明:
①template:
如果我们只需要在ng-view中插入简单的HTML内容,则使用该参数:
.when('/computers',{template:'这是电脑分类页面'})
②templateUrl:
如果我们需要在ng-view中插入HTML模板文件,则使用该参数:
$routeProvider.when('/computers', {
templateUrl: 'views/computers.html',
});
以上代码会从服务端获取 views/computers.html 文件内容插入到 ng-view 中。
③controller:
function、string或数组类型,在当前模板上执行的controller函数,生成新的scope。
④controllerAs:
string类型,为controller指定别名。
⑤redirectTo:
重定向的地址。
⑥resolve:
指定当前controller所依赖的其他模块。