Tôi đã có một mẫu AngularJS cực kỳ đơn giản, tôi đang cố gắng để có được định tuyến để làm việc nhưng khi tôi tải trang tôi chỉ nhìn thấy thẻ H1 từ index.html
của tôi.AngularJS thư mục con định tuyến không hoạt động, với <base> thẻ áp dụng
Ứng dụng của tôi nằm trong thư mục con, /angular-route/
và tôi biết rằng partials tồn tại, tôi có thể truy cập /angular-route/partials/interest.html
và trang hiển thị tốt.
Tôi đã bỏ lỡ điều gì đó thực sự cơ bản ở đây?
<html>
<head ng-app="myApp">
<title>AngularJS Routing</title>
<base href="/angular-route/" />
</head>
<body>
<h1>AngularJS Routing</h1>
<div ng-view></div>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js"></script>
<script>
'use strict';
var myApp = angular.module('myApp', []).
config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/interest', {
templateUrl: 'partials/interest.html',
controller: 'InterestCtrl'
}).
when('/catalogue', {
templateUrl: 'partials/catalogue.html',
controller: 'CatalogueCtrl'
}).
otherwise({redirectTo: '/interest'});
}]);
myApp.controller('InterestCtrl', function($scope, $routeParams) {
console.log('InterestCtrl');
});
myApp.controller('CatalogueCtrl', function($scope, $routeParams) {
console.log('CatalogueCtrl');
});
</script>
Xem [Làm thế nào để thiết lập vị trí gốc cho AngularJS Router ?] (http://stackoverflow.com/questions/17319715/how-to-set-root-location-for-angularjs-router/17321184#17321184) – Stewie
Điều đó tạo ra sự khác biệt, nếu tôi thêm ' ' –