Ich versuche meine erste Web-App mit MEAN-Stack zu bauen und ich habe ein Problem mit dem Angular-Routing.Angular routing funktioniert nicht
Wenn ich auf "Nerds" oder "Lacci" Link klicke, werden diese Seiten nicht angezeigt.
hier ist die Datei appRoute.js
angular.module('appRoutes', []).config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$routeProvider.when('/', {
templateUrl: '/public/views/home.html',
controller: 'MainController'
}) // nerds page that will use the NerdController
.when('/nerds', {
templateUrl: '/public/views/nerd.html',
controller: 'NerdController'
}).when('/lacci', {
templateUrl: '/public/views/lacci.html',
}).otherwise({ redirectTo: "/home" });
$locationProvider.html5Mode(true);}]);
Die beiden Dateien in differents Ordner sind. Wo liege ich falsch?
Ich könnte falsch sein, aber ich denke, die 'href's auf die Anchor Tags müssen '#' in Front [W3Schools Winkelrouting] (https://www.w3schools.com/angular/angular_routing.asp) wie 'Nerds' –
@SenSok er ist nicht mit UI-Router hier, also tut er nicht brauchen es –
@michele import ngRoute in Modul wie diesem 'angular.module ('appRoutes', ['ngRoute'])' –