I'm trying to display a page using a POST route, but so far no luck. The route is called from an Angular controller. The POST route is called properly - I get this in the node console POST /search 200 673ms
- but the page is not displayed. If I Invoke the route directly from the browser (i.e. typing the address) it works fine. Any help would be appreciated.
I've found a similar post, but the solution posted there doesn't work for me.
Here's my code:
Angular Controller
function SearchController($scope, $http){
$scope.product = {...};
$scope.search = function(form) {
$http.post('/search', { product : $scope.product });
};
}
Route definition
var products = require('../app/controllers/products')
app.post('/search', auth.requiresLogin, products.results)
Route controller
exports.results = function (req, res) {
// build query and fields var
Product.find(query, fields, function (err, docs) {
res.render('products/results', {
title: 'Search Results',
user: req.user ? JSON.stringify(req.user) : "null",
searchResults: docs ? docs : "null"
})
});
}
I'm using Express 3.3.3, Node 0.10.9 and Angular 1.0.3