Zurb's Foundation For Apps is using a special plugin that creates routes directly from each view, it will parse all the HTML files to find this kind of markdown structure :
---
name: items
url: /items
controller: ItemCtrl
---
which will use to generate the necessary angular Dynamic Routing code and use gulp to compile a routes.js
file which will contain this :
var foundationRoutes = [
{
"name":"items",
"url":"/items",
"controller":"ItemCtrl",
"path":"templates/items.html"
}
];
So my question is, if I want to change my templates path or restructre my app or if I need more advanced use for angular's ui-router specially state.resolve and state.views, Is there a way to replace the built-in Dynamic Routing plugin by a $stateProvider
instance without breaking any of the other F4A's built-in components ?
UPDATE : The special plugin is called Front Router and this is its Github Repository.
This solution solved my issue :
by @escapedcat from this github issue
page :
gulpfile.js
: comment out the FA router part :
// Copies your app's page templates and generates URLs for them
gulp.task('copy-templates', ['copy'], function() {
return gulp.src('./client/templates/**/*.html')
// .pipe(router({
// path: 'build/assets/js/routes.js',
// root: 'client'
// }))
.pipe(gulp.dest('./build/templates'))
;
});
index.html
: remove the routes.js
<script src="/assets/js/foundation.js"></script>
<!-- <script src="/assets/js/routes.js"></script> -->
<script src='//maps.googleapis.com/maps/api/js?sensor=false'></script>
<script src="/assets/js/app.js"></script>
app.js
: comment out the dynamicRouting modules and modify the config part :
angular.module('application', [
...
//foundation
'foundation',
// 'foundation.dynamicRouting',
// 'foundation.dynamicRouting.animations',
...
])
.config(
function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('yourstate', {
url: '/yoururl',
templateUrl: 'templates/yourTemplate.html',
controller: 'YourController',
resolve: {
// you can use resolve here, yay!
// promiseFooData: ['Restangular', function(Restangular) {
// return Restangular.one('foo').get();
// }]
}
});
})
.run(run)
;
You need a .state
entry for each route/template you had before.
In this example the part before looked like this :
---
name: yourstate
url: /yoururl
controller: YourController
---
NOTE: Animation may also be added to state
(after version 1.1 I guess) :
$stateProvider
.state('home', {
url: '/',
templateUrl: 'templates/home.html',
animation: {
enter: 'slideInDown',
leave: 'fadeOut'
}
});