javascript - Mean js - display updates in real time -
i'm new meanjs
, created new module adding products. these products displayed in home page. display in home page not getting updated real time
. added new product in 1 tab, , products list in other tab need refreshed see change. how can done @ real time
?
edit:
by updation meant is, when ever new record been added database, product display should update in realtime. need refresh page see newly added product. code is
client
$http.get('/latestproducts'). success(function(data, status, headers, config) { $scope.latestproducts = data; })
server
exports.getlatestproducts = function(req, res) { product.find().sort('-created').populate('user', 'displayname').exec(function(err, products) { if (err) { return res.status(400).send({ message: errorhandler.geterrormessage(err) }); } else { res.jsonp(products); } });
if mean browser tabs, mean.js won't if fo you. can use sockets inform server changes made , broadcast message active tabs refresh data. can try window.blur/window.focus events reload data.
if have list of products , product form on same page, have 2 options:
add saved item local collection after save poduct , recive success message server.
update local collection(get list of objects server) after save poduct , recive success message server.
Comments
Post a Comment