Ich versuche index.html
der URL mit html5Mode(true)
in AngularJS zu entfernen, dann ist dies der Code:Ausgabe mit html5Mode in AngularJS
angular.module('myApp', [
'ngRoute',
'myApp.filters',
'myApp.services',
'myApp.directives',
'myApp.controllers'
]).
config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider.when('/home', {templateUrl: 'views/home.html'});
$routeProvider.when('/about', {templateUrl: 'views/about.html'});
$routeProvider.otherwise({redirectTo: '/'});
}]);
Wenn ich schreibe nicht $locationProvider.html5Mode(true);
die URL zeigt:
localhost: (Port) /MyApplication/index.html
Wenn ich $locationProvider.html5Mode(true);
schreiben die uRL zeigt:
localhost: (port)
MyApplication
wird der URL entfernt. Und ich möchte die URL zeigt:
localhost: (Port)/MyApplication/
Was ich falsch mache? Was ist das Problem?
UPDATE:
Wie soll meine <a>
Tags zeigen? Im Moment habe ich:
<a href="#/about">About</>
Wenn ich auf den Link klicken, wird die URL zeigt:
localhost: (Port) /MyApplication/index.html#/about
I Ich bin damit verloren.
Vielen Dank im Voraus!
geben Sie bitte den Code an, in dem Sie die Routen definieren. (wo Sie $ routeProvider.when() anrufen) – bekite
@bekite Ich habe den Beitrag aktualisiert, Entschuldigung für die Verzögerung. Schöne Grüße. – Alavaros