需要帮助解决 angular 路由抛出 500 错误

Need help resolving angular routing throwing a 500 error

我不知道如何解决我的 500 问题。我不知道我是否需要在 express 或 angular 中进行更改。这是我的 main.js public 感谢任何帮助

var app = angular.module('myApp', ['ui.router'], function ($interpolateProvider) {
            $interpolateProvider.startSymbol('[[');
            $interpolateProvider.endSymbol(']]');
        });
app.config(function($stateProvider,$urlRouterProvider,$locationProvider){
// $locationProvider.hashPrefix('!');
// $urlRouterProvider.otherwise('/home');

$stateProvider
    .state('home',{
        url:'/home',
        templateUrl:'/home.html',
        controller: 'homeController'
    })

这是我在服务器端的app.js

swig = new swig.Swig();
// swig.setDefaults({varControls: ['<%=','%>']});
app.engine('html',swig.renderFile);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'html');

// uncomment after placing your favicon in /public
//app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', routes);

app.use('/api',apiRoutes);

Index.html 我确保使用了正确的路由器语法

  <div ui-view> 

  </div>

我不会去主页。不知道为什么。我在路线上不断收到错误 http://localhost:3000/#/home

它归结为您的 home.html 文件所在的位置,即在哪个目录中。假设它在 "allhtmls" 目录中。然后你需要做两件事:

app.use('/myhome', express.static(__dirname + '/allhtmls'));// or use /client/allhtmls if under client directory - best practice

state('home',{
        url:'/home',
        templateUrl:'/myhome/home.html',
        controller: 'homeController'