gulp を実行すると、サーバーが次のメッセージで起動しました: cannot get /. localhost:3000/app/index.html を指すと、サイトは localhost:3000/home にリダイレクトされ、正しく機能します。ただし、ページをリロードすると、/home を取得できません。
次の構成を確認して、何か不足していないかどうかを確認してください。
アクセスするパス: app/index.html
これは私の gulpfile.js です:
var gulp = require('gulp'),
nodemon = require('gulp-nodemon'),
jshint = require('gulp-jshint'),
browserSync = require('browser-sync')
modRewrite = require('connect-modrewrite');
gulp.task('lint', function () {
gulp.src('app/js/*.js').pipe(jshint());
});
gulp.task('serve', function() {
browserSync({
server: {
baseDir: "./",
middleware: [
modRewrite([
'!\\.\\w+$ /index.html [L]'
])
]
}
});
});
gulp.task('default', ['lint', 'serve'], function() {
gulp.watch('app/js/*.js', ['lint', browserSync.reload]);
});
角度ルート ファイル:
$urlRouterProvider.otherwise("/home");
$stateProvider
.state('home', {
url: "/home",
templateUrl: "app/partials/home.html",
controller: 'HomeCtrl'
})
...
どうもありがとう!