分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 前端开发

AngularJS路由

发布时间:2023-09-06 02:18责任编辑:白小东关键词:AngularAngularJS

1、AngularJS路由

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

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

http://runoob.com/#!/firsthttp://runoob.com/#!/secondhttp://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所依赖的其他模块});

AngularJS路由

原文地址:https://www.cnblogs.com/85-Q/p/9783698.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved