So, I've been looking all day for this, but I can't find anything about it. Suppose, I have a webapp with a settings page www.example.com/settings. What do I do if I want to add subpages to this settings pages, e.g. www.example.com/settings/account. Below you can find my current implementation, but that isn't working...
var Example = angular.module('ExampleApp', ['ngRoute']);
Example.config(function($routeProvider, $locationProvider) {
$routeProvider
// route for account settings
.when('/settings/account', {
templateUrl : 'views/settings/account.php',
controller : 'SettingsController'
})
// route for profile settings
.when('/settings/profile', {
templateUrl : 'views/settings/profile.php',
controller : 'SettingsController'
})
// route for the settings
.when('/settings', {
templateUrl : 'views/settings.php',
controller : 'SettingsController'
});
$locationProvider.html5Mode(true);
});
And this is an example of the settings/account view:
<div ng-controller="SettingsController">
<h1>ExampleApp</h1>
<h4>Account | Settings</h4>
</div>
======================================
I added the code suggested to main.js, but now it keeps going to /home
Example.config(function($stateProvider, $urlRouterProvider) {
//
// For any unmatched url, redirect to /home
$urlRouterProvider.otherwise("/home");
//
// Now set up the states
$stateProvider
.state('home', {
url: "/home",
templateUrl: "views/home.html"
})
.state('add', {
url: "/add",
templateUrl: "views/add.html"
})
.state('edit', {
url: "/edit",
templateUrl: "views/edit.html"
})
.state('settings', {
url: "/settings",
templateUrl: "views/settings.html"
})
.state('account', {
url: "/settings/account",
templateUrl: "views/settings/account.html"
});
});
ContentVeil.jsandmtgm.js.