angularJS 路由配置
2018-03-01 16:36
302 查看
$routeProvider.when(url, {
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所依赖的其他模块。
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所依赖的其他模块。
相关文章推荐
- AngularJS 路由以及模块配置
- angularjs 配置路由按需加载html\js文件[不依赖第三方插件]
- angularjs 配置路由按需加载html\js文件[不依赖第三方插件]
- AngularJs之ui.router路由基本配置及传参方法
- AngularJS配置路由ngRoute的使用
- 第3篇:angularJS使用ui-router的嵌套路由配置
- AngularJS路由的简单配置
- angularJS的路由配置——转
- AngularJS开发WebApp的路由配置
- AngularJS 路由配置对象
- AngularJS 配置路由
- angularjs路由配置$route以及案例展示
- AngularJS 路由以及模块配置
- AngularJS路由以及模块配置
- angularJS1 路由配置
- 默认路由与浮动路由,交换机配置(笔记)
- 关于思科拓扑中没有路由器进行三层交换机VLAN间路由的配置问题
- Ionic 入门与实战之第三章:Ionic 项目结构以及路由配置
- ionic的路由配置及参数传递