Search code examples
javascriptangularjsangularjs-routing

AngularJS routing dont work on child folders


Everything works except for the folder portfolio/acura when I go to the link it sends me to the portfolio page. but if i make i take out the "portfolio" and just makes it /acura it works just fine.

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'});

    ;


});

Solution

  • You forgot the /

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