这个解决方案解决了我的问题:
来自此 github 问题页面的 @escapedcat :
gulpfile.js
:注释掉FA路由器部分:
// 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
: 去除那个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
:注释掉dynamicRouting模块并修改配置部分:
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)
;
您需要.state
为之前拥有的每条路线/模板输入一个条目。在此示例中,之前的部分如下所示:
---
name: yourstate
url: /yoururl
controller: YourController
---
注意:动画也可以添加到state
(我猜是 1.1 版之后):
$stateProvider
.state('home', {
url: '/',
templateUrl: 'templates/home.html',
animation: {
enter: 'slideInDown',
leave: 'fadeOut'
}
});