的角教程调用route provider
明确以下,(适于简洁起见)
angular.module('myApp', []).
config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/myResource1',
{templateUrl: 'partials/myView1.html', controller: MyController1}).
when('/myResource2',
{templateUrl: 'partials/myView2.html', controller: MyController2}).
otherwise({redirectTo: '/index.html'});
}]);
我们可以定义route provider
分别 ,然后借助调用它angular directive
下面? 有这样一个现有的指令? 否则,如何让经过呢?
function MyRouteProvider($routeProvider) {
$routeProvider.
when('/myResource1',
{templateUrl: 'partials/myView1.html', controller: MyController1}).
when('/myResource2',
{templateUrl: 'partials/myView2.html', controller: MyController2}).
otherwise({redirectTo: '/index.html'});
};
<html ng-app="myApp">
<head>
<script src="lib/angular.js"></script>
<script src="js/MyControllers.js"></script>
<script src="js/MyRouteProvider.js"></script>
</head>
<body ng-routeProvider="MyRouteProvider">
...
</body>
</html>
myApp
|__index.html
|__js
| |__MyControllers.js
| |__MyRouteProvider.js
|__partials
|__myView1.html
|__myView2.html