AngularJS路由不适用于子文件夹

AngularJS routing dont work on child folders

本文关键字:文件夹 适用于 不适用 路由 AngularJS      更新时间:2023-09-26

除了文件夹投资组合/讴歌之外,当我转到它发送到投资组合页面的链接时,一切都可以正常工作。 但是如果我让我取出"投资组合"并让它/Acura,它就可以正常工作。

http://www.jaysg.com/#/portfolio/acura

脚本.js

// create the module and name it scotchApp
    // also include ngRoute for all our routing needs
var site = angular.module('site', ['ngRoute', 'ngAnimate']);
// configure our routes
site.config(function($routeProvider) {
    $routeProvider
        // route for the home page
        .when('/', {
            templateUrl : 'templates/home.html',
            controller  : 'mainController'
        })
        .when('/home', {
            templateUrl : 'templates/home.html',
            controller  : 'mainController'
        })
        // route for the about page
        .when('/about', {
            templateUrl : 'templates/about.html',
            controller  : 'aboutController'
        })
        // route for the about page
        .when('/portfolio', {
            templateUrl : 'templates/portfolio.html',
            controller  : 'portfolioController'
        })
        // route for the subfolder this is what dont work
        .when('portfolio/acura', {
            templateUrl : 'templates/portfolio/acuransx/acura.html',
            controller  : 'acuransxController'
        })

        // route for the contact page
        .when('/contact', {
            templateUrl : 'templates/contact.html',
            controller  : 'contactController'
        })
        .otherwise({redirectTo:'/home'});
    ;

});

你忘了/

 .when('/portfolio/acura', { ...