javascript - Share updated variable with factory (variable scope) -
i share updated variable (updated function) through factory (angularjs)
i have following factory:
apptspsrv.factory('shared', function(db) { var entities; var getentities = function(){ db.query('getentities', function(err, doc) { if (err) { console.log(err); } else { entities = doc.rows; } }); }; getentities(); return { getentities: function() { return entities; } } });
when call factory's function controller 'undifined':
console.log(shared.getentities());
why , how can fix this?
Comments
Post a Comment