【问题标题】:Angular Routing; exlamation mark beside hashtag in url角路由;网址中标签旁边的感叹号
【发布时间】:2017-01-22 00:14:22
【问题描述】:

我试图做路由,但我做不到。

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。但这次没有代码起作用。

我该怎么办?

【问题讨论】:

    标签: angularjs routing route-provider location-provider


    【解决方案1】:

    你不能使用 href 属性 div 标签。您应该在 div 标签中创建标签。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-24
      • 2013-04-13
      • 2014-12-15
      • 1970-01-01
      • 2020-10-13
      相关资源
      最近更新 更多