Ich habe ein Problem mit meinem Code mit ng-route. Die Adresse im Browser ändert sich, aber auf meiner Seite sind alle Elemente immer noch gleich. Hier ist mein Code:ng-Route funktioniert nicht
var app=angular.module('mainApp',['ngRoute']);
app.config('$routeProvider', function($routeProvider){
$routeProvider
.when('/',{
templateUrl: 'home.html'
})
.when('/about', {
templateUrl: 'about.html'
})
.when('/contact', {
templateUrl: 'contact.html'
})
.otherwise({
\t \t \t redirectTo: '/'
\t \t \t });
});
app.controller('mainCtrl',function($scope){
});
<div ng-controller="mainCtrl">
\t <div>
\t \t <nav>
\t \t \t <ul>
\t \t \t \t <li><a href="#/">Home</a></li>
\t \t \t \t <li><a href="#/about">About us</a></li>
\t \t \t \t <li><a href="#/contact">Contact</a></li>
\t \t \t </ul>
\t \t \t </nav>
\t </div>
\t <br/>
\t <div ng-view ></div>
</div>
Ich habe drei Subsite mit einfachen Absätzen (zu Hause, über und Kontakt html.).
Können Sie mir helfen?
kann sein "URL" ist nicht korrekt. –
Mein Haupt-HTML ist Desktop/SS/index.html #/Wenn ich auf "Über uns" klicke, ändert sich das auf Desktop/SS/index.html #/ab, aber auf der Seite passiert nichts. Wenn ich Url von templateUrl lösche, ist alles korrekt – Ernest