AngularJS路由

1、AngularJS路由

        允许我们通过不同的URL访问不同的内容,可以实现多视图的单页WEB应用。

URL的形式为http://runoob.com/first/page,但在单页Web应用中AngularJS痛过#!+标记实现,例如:

http://runoob.com/#!/first
http://runoob.com/#!/second
http://runoob.com/#!/third

2、路由设置对象

       可以通过不同的模板来实现;

      template:需要在ng-view中插入简单的HTML内容,则使用该参数;

     templateUrl:需要在ng-view中插入HTML模板文件,则使用该参数;

     controller:function、string或数组类型,在当前模板上执行的controller函数,生成新的scope;

     controllerAS:string类型,为controller指定别名;

     redirectTo:重定向的地址;

    resolve::指定当前controller所依赖的其他模块;

$routeProvider.when(url,{
    template:string, //在ng-view中插入简单的html内容
    templateUrl:string, //在ng-view中插入html模版文件
    controller:string,function / array, //在当前模版上执行的controller函数
    controllerAs:string, //为controller指定别名
    redirectTo:string,function, //重定向的地址
    resolve:object<key,function> //指定当前controller所依赖的其他模块
});

 

转载于:https://www.cnblogs.com/85-Q/p/9783698.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值