您的位置:首页 > Web前端 > AngularJS

Angular.js路由实现

2020-06-04 07:44 357 查看

需要注册ngRoute服务 引入相关JS文件

var myapp = angular.module(‘test’,[‘ngRoute’,‘ngAnimate’,‘testControls’,‘myService’]);
myapp.controller(‘index’, [ ‘scope′,′scope', 'scope′,′http’, ‘location′,′myService1′]);myapp.config(function(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’,[]);//申明自定义模块

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: