angular.js 1.6版本;
1.实例化:
var app = angular.module('app',[]).controller('myapp',['$scope',function ($scope){}]);
2-1.原生路由:
<a href="#/home"></a>
<div ng-view></div>
1> 注入var app = angular.module('app',[ngRouter])
2> 配置app.config(['$routerProvider','$locationProvider',function($routerProvider,$locationProvider){
$locationProvider.hashPrefix('');//1.6版本变化;
$routerProvider
.when('/index'{
templateUrl:"./index.html",
controller:"con"
})
.otherwise({redirectTo:"/index"});
}])
2-2.ui-router
ng-view => ui-view
<a href="#/home"></a>
<div ui-view></div>
1> 模块注入:
var app = angular.module('app',['ui.router']);
2> 配置路由
app.config(['$stateProvider','$locationProvider','$urlRouterProvider',function($stateProvider,$locationProvider,$urlRouterProvider){
$locationProvider.hashPrefix('');
$urlRouterProvider.otherwise('/index');
$stateProvider.state('home',{
url:"/home",
templateUrl:"./home.html",
controller:function(){}
})
}])
3.过滤器
app.filter('test',function(){
return function(input){
//code...
}
})