I have a simple angular
app managed by Grunt.js
. I use the angular router for different pages:
index.html
...
<body ng-app="app">
...
<div ng-view></div>
...
</div>
...
_users.html
<h1>Users</h1>
...
app.js
var app = angular.module('app', ['ngRoute']);
app.config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/', {
templateUrl: 'views/_home.html',
controller: 'HomeCtrl'
}).
when('/users', {
templateUrl: 'views/_users.html',
controller: 'UsersCtrl'
}).
otherwise({ redirectTo: '/' });
}]);
// ... controllers
The routing works fine for client side rendering, e.g requests of the form site.com
, site.com/#/users
, etc. If I apply $locationProvider.html5Mode({ enabled: true })
, a direct call for site.com/users
will fail, because there are no users.html
or users/index.html
files. Is there a smart grunt plugin which knows to render the views inside the layout when building a distribution directory? That is, generate a directory structure like for every nested view:
dist
├── index.html
└── users
│ └── index.html
├── css
│ └── app.css
└── js
└── app.js
Thanks.