我正在使用intellij,它为我创建了一个模板。我正在尝试使用:
app.config(function($routeProvider, $locationProvider) {
指导我的网页。但是当前呈现的默认索引页面。这只是我想弄清楚事情是如何联系的。
configuration.js
app.config(function($routeProvider, $locationProvider) {
$routeProvider.when('/',{
templateUrl: "app/pages/mainPage/mainPage.html",
controller:"mainPageController"
});
$routeProvider.otherwise({redirectTo: '/view1'});
});
mainPage.html
<div>
<h2>Hello World</h2>
</div>
的index.html
<body>
<ul class="menu">
<li><a href="#/view1">view1</a></li>
<li><a href="#/view2">view2</a></li>
</ul>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div ng-view></div>
<div>Angular seed app: v<span app-version></span></div>
<!-- In production use:
<script src="//ajax.googleapis.com/ajax/libs/angularjs/x.x.x/angular.min.js"></script>
-->
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="app.js"></script>
<script src="view1/view1.js"></script>
<script src="view2/view2.js"></script>
<script src="components/version/version.js"></script>
<script src="components/version/version-directive.js"></script>
<script src="components/version/interpolate-filter.js"></script>
<script src="pages/mainPage/mainPageController.js"></script>
<script src="configuration.js"></script>
</body>
</html>
app.js
// Declare app level module which depends on views, and components
var app = angular.module('myApp', [
'ngRoute',
'myApp.view1',
'myApp.view2',
'myApp.version'
]);
view1.js
'use strict';
angular.module('myApp.view1', ['ngRoute'])
//.config(['$routeProvider', function($routeProvider) {
// $routeProvider.when('/view1', {
// templateUrl: 'view1/view1.html',
// controller: 'View1Ctrl'
// });
//}])
.controller('View1Ctrl', [function() {
}]);
view2.js
'use strict';
angular.module('myApp.view2', ['ngRoute'])
//.config(['$routeProvider', function($routeProvider) {
// $routeProvider.when('/view2', {
// templateUrl: 'view2/view2.html',
// controller: 'View2Ctrl'
// });
//}])
.controller('View2Ctrl', [function() {
}]);
我正在尝试渲染mainPage.html并处理一个文件中的所有重定向,即configuration.js