I have experience developing angular apps, but I am new to the mean stack, I am trying out the mean stack and have an express server running and a angular site running. My express if for my REST api primarily, but would like to have an entry point to point back to the my client in a case of an unknown url to the server: server.js:
// Setup View Engines
app.set('views', path.join(__dirname, 'public'));
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
// Serve files from your "public" directory
app.use('/public', express.static(path.join(__dirname + 'public')));
// Serve files from your "bower_components" directory
app.use('/bower_components', express.static(path.join(__dirname + '/bower_components')));
// GET index.html route
app.get('/', function(req, res) {
return res.render('index');
});
my angular resides in Public folder and here is my index.html file:
<!DOCTYPE html>
<html ng-app="havuraApp">
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div>
main
<ui-view></ui-view>
</div>
</body>
<script src="../bower_components/angular/angular.js"></script>
<script src="../bower_components/angular-ui-router/release/angular-ui-router.js"></script>
<script src="../bower_components/angular-ui-bootstrap/index.js"></script>
<script src="../bower_components/angular-resource/angular-resource.js"></script>
<script src="app.js"></script>
<!--services-->
<script src="Services/svcModule.js"></script>
<script src="Services/userSvc.js"></script>
<!--dashboard-->
<script src="Views/dashboard/dashboard.module.js"></script>
<script src="Views/dashboard/config.route.js"></script>
<script src="Views/dashboard/dashboard.js"></script>
</html>
If i hit the angular site index.html, my loads my correct default route page, but when I hit it using the express route, it loads the html only and not the ui-view part of it.
Any help will be appreciated.