我试图做路由,但我做不到。
app.js中的相关代码;
var app = angular.module("app",['ngRoute']);
app.config(["$routeProvider",function($routeProvider){
$routeProvider.
when('/', {
templateUrl:'pages/home.php'
}).
when('/notifications', {
templateUrl:'pages/notifications.php'
}).
when('/messages', {
templateUrl:'pages/messages.php'
}).
when('/search', {
templateUrl:'pages/search.php'
}).
otherwise({
rediectTo: '/'
});
}])
index.php中的相关代码;
<div id="ifmenu">
<div class="ifmitem" href="/#/">Anasayfa</div>
<div class="ifmitem" href="/#/notifications">Bildirimler</div>
<div class="ifmitem" href="/#/messages">Mesajlar</div>
<div class="ifmitem" href="/#/search">Arama</div>
</div>
<ng-view></ng-view>
网址中的标签旁边有感叹号。像这样:(localhost/app/#!)。我可以使用 else() 函数获取 home.php,但链接不起作用。我在互联网上调用了这个问题的解决方案。我看到我应该添加这些亚麻布;
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
我在 .config 中添加了 $locationProvider。但是这次没有代码起作用。
我应该怎么办?