angularjsroutesroute-providerlocation-provider

Angular Routing; exlamation mark beside hashtag in url


I trying to do routing but i can't.

Related codes in 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: '/'
        });

}])

Related codes in 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>

Have exclamation mark beside hashtag in url. Like this: (localhost/app/#!). And i can getting home.php with otherwise() function but links don't work. I called solution of this problem in internet. I saw that I should' to add these linen;

$locationProvider.html5Mode({
    enabled: true,
    requireBase: false
});

And I added $locationProvider in .config. But this time none code worked.

What should' i do?


Solution

  • You can't use href attributes div tags. You should create tag in div tags.