I have my index.html, when I click on a button, it calls a angular service that use $resource.
var serviceRest = $resource(URL_API, null,
{
"connect" : { method: "GET", url: "http://localhost/login"}
});
And then in my expressJS route I have this :
router.get('/',function(req,res){
console.log("Hi there");
res.sendFile('../public/views/login.html', {root: __dirname});
});
But it does nothing. Nothing happens but my console log display so my sendFile might be false... I stay on my index.html.
| -- Agenda
| -- public
| -- views
| -- login.html
| -- controllers
| -- routes.js
My router file is in ./controllers, and my login.html is in ./public/views
EDIT :
Ok, so the problem is not a path problem. But, in all solution that I tried, only one gave me a good result.
res.sendFile(path.join(__dirname, '../public/views/login.html'));
After that, I asked myself "What I am returning in the Angular Service with the $resource. And this is at this moment that I saw that my connect() function :
var serviceRest = $resource(URL_API, null,
{
"connect" : { method: "GET", url: "http://localhost/login"}
});
return {
connect: function() {
console.log("connect");
console.log(serviceRest.connect());
return serviceRest.connect();
}
}
This console.log(serviceRest.connect()); shows me a Promise in the browser console. And this is a huge array with one character per element, that containing my login.html code lol. Funny but not help me haha