can someone explain me how to combine nodejs (hapi server) with AngularJs? I thought I can just catch every request made to my Hapi server and react to those requests using angularjs' routes / REST etc…
The server is running and serves me my index.html as I expect, but however I am to stupid to hook in my app.js for the angular stuff. I guess my approach is completely wrong.
Hapi
server.route({
method: 'GET',
path: '/{p*}',
handler: function (request, reply) {
reply.file('public/index.html');
}
});
index.html (header)
<script src="CDN/angular.min.js"></script>
<script src="./app.js"></script>
Inline AngularJs code in my index.html works properly. I'm thankful to every response or some resources I can look at.
your approach is for an api and not for serving static files. Server static files like this:
// static file
server.route({
method: 'GET',
path: '/{param*}',
handler: {
directory: {
path: Path.join(__dirname, 'public/app')
}
}
});
see more info here http://hapijs.com/tutorials/serving-files