需要注册ngRoute服务 引入相关JS文件
var myapp = angular.module(‘test’,[‘ngRoute’,‘ngAnimate’,‘testControls’,‘myService’]);
myapp.controller(‘index’, [ ‘
s
c
o
p
e
′
,
′
scope', '
scope′,′http’, ‘
l
o
c
a
t
i
o
n
′
,
′
m
y
S
e
r
v
i
c
e
1
′
]
)
;
m
y
a
p
p
.
c
o
n
f
i
g
(
f
u
n
c
t
i
o
n
(
location', 'myService1']); myapp.config(function(
location′,′myService1′]);myapp.config(function(routeProvider){
$routeProvider
.when(’/b’,{
templateUrl:‘b.html’,
controller:‘b’
})
.when(’/a’,{
templateUrl:‘a.html’,
controller:‘a’
})
.otherwise({
redirectTo:‘c’
})
});
var app = angular.module(‘testControls’,[]);//申明自定义模块