AngularJS 路由不适用于子文件夹
AngularJS routing dont work on child folders
除了文件夹 portfolio/acura 之外,其他一切正常,当我转到 link 时,它会将我转到投资组合页面。但是如果我把 "portfolio" 拿出来,然后把它做成 /acura,它就可以正常工作了。
http://www.jaysg.com/#/portfolio/acura
// script.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', { ...
除了文件夹 portfolio/acura 之外,其他一切正常,当我转到 link 时,它会将我转到投资组合页面。但是如果我把 "portfolio" 拿出来,然后把它做成 /acura,它就可以正常工作了。
http://www.jaysg.com/#/portfolio/acura
// script.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', { ...