<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
li {
list-style-type: none;
}
a {
float: left;
line-height: 60px;
display: block;
text-decoration: none;
color: black;
font-size: 30px;
width: 33.3%;height: 60px;
}
h1{margin-left: 10px;}
</style>
<script type="text/javascript" src="js/angular.min.js"></script>
<!--引入路由文件-->
<script src="https://apps.bdimg.com/libs/angular-route/1.3.13/angular-route.js"></script>
<script>
window.onload = function() {
var _span = document.getElementsByTagName('a');
var CBody = document.getElementsByTagName('a');
_span[0].onclick = function() {
CBody[0].style.background = "#CCE8CF";
CBody[1].style.background = "#fff";
CBody[2].style.background = "#fff";
}
_span[1].onclick = function() {
CBody[0].style.background = "#fff";
CBody[1].style.background = "#CCE8CF";
CBody[2].style.background = "#fff";
}
_span[2].onclick = function() {
CBody[0].style.background = "#fff";
CBody[1].style.background = "#fff";
CBody[2].style.background = "#CCE8CF";
}
var h = document.getElementsByTagName('h1');
var hh = document.getElementsByTagName('h1');
h[0].onclick = function() {
hh[0].style.background = "#CCE8CF";
hh[1].style.background = "#fff";
hh[2].style.background = "#fff";
}
h[1].onclick = function() {
hh[0].style.background = "#fff";
hh[1].style.background = "#CCE8CF";
hh[2].style.background = "#fff";
}
h[2].onclick = function() {
hh[0].style.background = "#fff";
hh[1].style.background = "#fff";
hh[2].style.background = "#CCE8CF";
}
}
</script>
</head>
<body ng-app='routeDemo'>
<!--左边栏-->
<div id="navigator" style="width: 30%;height: 60px;border: 1px solid #000000;margin-left: 35%;">
<!--菜单-->
<center>
<a href="#/home">商品列表</a>
<a href="#/woman">用户信息</a>
<a href="#/man">地址信息</a>
</center>
</div>
<!--右边栏-->
<div style="width: 80%;display: inline-block;height: 300px;border: 1px solid #aaa;margin-left: 10%;">
<div ng-view=""></div>
</div>
</body>
<script type="text/ng-template" id="index.home.html">
<h1>电脑1</h1>
<h1>电脑2</h1>
<h1>电脑3</h1>
</script>
<script type="text/ng-template" id="index.woman.html">
<h1>张三</h1>
<h1>李四</h1>
<h1>王五</h1>
</script>
<script type="text/ng-template" id="index.man.html">
<h1 onclick="">上帝一街</h1>
<h1>上帝二街</h1>
<h1>上帝三街</h1>
</script>
<script type="text/javascript">
angular.module('routeDemo', ['ngRoute'])
.controller('HomeController', function($scope, $route) {
$scope.$route = $route;
})
.controller('WomanController', function($scope, $route) {
$scope.$route = $route;
})
.controller('WomanController', function($scope, $route) {
$scope.$route = $route;
})
.controller('ManController', function($scope, $route) {
$scope.$route = $route;
})
.controller('LifeController', function($scope, $route) {
$scope.$route = $route;
})
.controller('CookController', function($scope, $route) {
$scope.$route = $route;
})
//配置$routeProvider用来定义路由规则
//$routeProvider为我们提供了when(path,object)& other(object)函数按顺序定义所有路由,函数包含两个参数:
//@param1:url或者url正则规则
//@param2:路由配置对象
.config(function($routeProvider) {
$routeProvider.
when('/home', {
//templateURL:插入ng-view的HTML模板文件
templateUrl: 'index.home.html',
controller: 'HomeController'
}).
when('/woman', {
templateUrl: 'index.woman.html',
controller: 'WomanController'
}).
when('/man', {
templateUrl: 'index.man.html',
controller: 'ManController'
}).
when('/life', {
templateUrl: 'index.life.html',
controller: 'LifeController'
}).
when('/cook', {
templateUrl: 'index.cook.html',
controller: 'CookController'
})
})
</script>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
li {
list-style-type: none;
}
a {
float: left;
line-height: 60px;
display: block;
text-decoration: none;
color: black;
font-size: 30px;
width: 33.3%;height: 60px;
}
h1{margin-left: 10px;}
</style>
<script type="text/javascript" src="js/angular.min.js"></script>
<!--引入路由文件-->
<script src="https://apps.bdimg.com/libs/angular-route/1.3.13/angular-route.js"></script>
<script>
window.onload = function() {
var _span = document.getElementsByTagName('a');
var CBody = document.getElementsByTagName('a');
_span[0].onclick = function() {
CBody[0].style.background = "#CCE8CF";
CBody[1].style.background = "#fff";
CBody[2].style.background = "#fff";
}
_span[1].onclick = function() {
CBody[0].style.background = "#fff";
CBody[1].style.background = "#CCE8CF";
CBody[2].style.background = "#fff";
}
_span[2].onclick = function() {
CBody[0].style.background = "#fff";
CBody[1].style.background = "#fff";
CBody[2].style.background = "#CCE8CF";
}
var h = document.getElementsByTagName('h1');
var hh = document.getElementsByTagName('h1');
h[0].onclick = function() {
hh[0].style.background = "#CCE8CF";
hh[1].style.background = "#fff";
hh[2].style.background = "#fff";
}
h[1].onclick = function() {
hh[0].style.background = "#fff";
hh[1].style.background = "#CCE8CF";
hh[2].style.background = "#fff";
}
h[2].onclick = function() {
hh[0].style.background = "#fff";
hh[1].style.background = "#fff";
hh[2].style.background = "#CCE8CF";
}
}
</script>
</head>
<body ng-app='routeDemo'>
<!--左边栏-->
<div id="navigator" style="width: 30%;height: 60px;border: 1px solid #000000;margin-left: 35%;">
<!--菜单-->
<center>
<a href="#/home">商品列表</a>
<a href="#/woman">用户信息</a>
<a href="#/man">地址信息</a>
</center>
</div>
<!--右边栏-->
<div style="width: 80%;display: inline-block;height: 300px;border: 1px solid #aaa;margin-left: 10%;">
<div ng-view=""></div>
</div>
</body>
<script type="text/ng-template" id="index.home.html">
<h1>电脑1</h1>
<h1>电脑2</h1>
<h1>电脑3</h1>
</script>
<script type="text/ng-template" id="index.woman.html">
<h1>张三</h1>
<h1>李四</h1>
<h1>王五</h1>
</script>
<script type="text/ng-template" id="index.man.html">
<h1 onclick="">上帝一街</h1>
<h1>上帝二街</h1>
<h1>上帝三街</h1>
</script>
<script type="text/javascript">
angular.module('routeDemo', ['ngRoute'])
.controller('HomeController', function($scope, $route) {
$scope.$route = $route;
})
.controller('WomanController', function($scope, $route) {
$scope.$route = $route;
})
.controller('WomanController', function($scope, $route) {
$scope.$route = $route;
})
.controller('ManController', function($scope, $route) {
$scope.$route = $route;
})
.controller('LifeController', function($scope, $route) {
$scope.$route = $route;
})
.controller('CookController', function($scope, $route) {
$scope.$route = $route;
})
//配置$routeProvider用来定义路由规则
//$routeProvider为我们提供了when(path,object)& other(object)函数按顺序定义所有路由,函数包含两个参数:
//@param1:url或者url正则规则
//@param2:路由配置对象
.config(function($routeProvider) {
$routeProvider.
when('/home', {
//templateURL:插入ng-view的HTML模板文件
templateUrl: 'index.home.html',
controller: 'HomeController'
}).
when('/woman', {
templateUrl: 'index.woman.html',
controller: 'WomanController'
}).
when('/man', {
templateUrl: 'index.man.html',
controller: 'ManController'
}).
when('/life', {
templateUrl: 'index.life.html',
controller: 'LifeController'
}).
when('/cook', {
templateUrl: 'index.cook.html',
controller: 'CookController'
})
})
</script>
</html>