简单的angular路由
来源:互联网 发布:php递归99乘法表 编辑:程序博客网 时间:2024/06/01 21:38
//导包的时候一定要注意先导入angular包再导入route包
<!--
路由:
路线
通过超链接,连接不同的页面。
#,在浏览器中,#后面的会被忽略掉
点击不同的超链接,加载不同的页面
子页面:
就是要加载到主页面的页面
混合开发,其实就是开发单页面应用。
//路由三个时间
.页面开始加载的时间
路由有几个常用的事件:
路由:
路线
通过超链接,连接不同的页面。
#,在浏览器中,#后面的会被忽略掉
点击不同的超链接,加载不同的页面
子页面:
就是要加载到主页面的页面
混合开发,其实就是开发单页面应用。
//路由三个时间
.页面开始加载的时间
路由有几个常用的事件:
$routeChangeStart:这个事件会在路由跳转前触发
$routeChangeSuccess:这个事件在路由跳转成功后触发
$routeChangeError:这个事件在路由跳转失败后触发
-->
<style type="text/css">
ul{
list-style: none;
}
ul li{
float: left;
width: 60px;
}
a{
text-decoration: none;
}
</style>
-->
<style type="text/css">
ul{
list-style: none;
}
ul li{
float: left;
width: 60px;
}
a{
text-decoration: none;
}
</style>
<body ng-app="myApp" ng-controller="myCtrl">
<ul>
<li><a href="#/">主頁</a></li>
<li><a href="#/goods">購物車</a></li>
<li><a href="#/me">我的</a></li>
</ul>
<br>
<!--<ng-view></ng-view>-->
<!--
ng-view是个容器,将子页面放入这里
-->
<div ng-view>
</div>
<script type="text/javascript">
var mo = angular.module("myApp",["ngRoute"]);//将路由对象注入模块儿
mo.controller("myCtrl",function($scope){
})
//配置路由
// $routeProvider 内置对象,配置路由的
//templateUrl加载路径
mo.config(function($routeProvider){
// $routeProvider.when("/",{templateUrl:"zhuye.html"});
//
// $routeProvider.when("/goods",{templateUrl:"goods.html"})
//
// $routeProvider.when("/me",{templateUrl:"me.html"})
$routeProvider.when("/",{template:"我是主页"}).when("/goods",{templateUrl:"goods.html"}).when("/me",{templateUrl:"me.html"});
});
</script>
</body>
<ul>
<li><a href="#/">主頁</a></li>
<li><a href="#/goods">購物車</a></li>
<li><a href="#/me">我的</a></li>
</ul>
<br>
<!--<ng-view></ng-view>-->
<!--
ng-view是个容器,将子页面放入这里
-->
<div ng-view>
</div>
<script type="text/javascript">
var mo = angular.module("myApp",["ngRoute"]);//将路由对象注入模块儿
mo.controller("myCtrl",function($scope){
})
//配置路由
// $routeProvider 内置对象,配置路由的
//templateUrl加载路径
mo.config(function($routeProvider){
// $routeProvider.when("/",{templateUrl:"zhuye.html"});
//
// $routeProvider.when("/goods",{templateUrl:"goods.html"})
//
// $routeProvider.when("/me",{templateUrl:"me.html"})
$routeProvider.when("/",{template:"我是主页"}).when("/goods",{templateUrl:"goods.html"}).when("/me",{templateUrl:"me.html"});
});
</script>
</body>
//还有三个子页面goods zhuye me三个可以随便布局只是为了可以调用
阅读全文
0 0
- 简单的angular路由
- angular路由的简单应用
- angular路由(简单)
- angular 简单路由
- angular中的路由简单使用
- angular路由的使用
- angular的路由实现,ngRoute
- angular路由的深入理解
- angular的路由表格添加
- angular路由的使用案例
- angular之路由的理解
- angular js ng-route 路由简单实例
- Angular 路由 过滤 实行简单分页
- angular ui-router:简单的单页面嵌套路由的实现过程
- angular 路由
- angular路由
- Angular路由
- angular 路由
- POJ 1039.Pipe
- Sql--列操作
- 涂威威:第四范式经验与思考分享
- 致研究生:一定要从这3个方面审视你的研究方向
- Could not satisfy explicit device specification '/job:worker/task:0/device:GPU:1' because no support
- 简单的angular路由
- c语言实现的扫雷游戏
- bitnode bitree
- Flashsim中关于FAST算法实现的代码解析
- 哈尔滨理工大学第七届程序设计竞赛初赛(高年级组)题解
- dubbo的SPI扩展实现原理简解
- Python基础-Python2.7安装Pip
- python语法之@修饰器
- 关于安卓被开发中出现java.lang.RuntimeException: Unable to start activity ComponentInfo