angularjs - Angular and Breeze fetchMetaData -
i'm curious if there alternatives fetching meta data breeze when using angular. since $q , q promises don't play nice each other decided use q.js promises , not $q. in controller i'm checking if metadatastore empty:
if (maindataservice.manager.metadatastore.isempty()) { $log.info('metadatastore empty') ; maindataservice.getmetadata() .then(function () { enablecreatebutton(); }); }
the basic idea if don't have meta data go fetch , enable buttons allow me create new record.
to accomplish define q promise in data service after breeze resolves promise resolve promise.
function getmetadata() { var mymetadatapromise = q.defer(); q.delay(0).then(function () { manager.metadatastore.fetchmetadata(servicename).then(function () { mymetadatapromise.resolve(); }); }); return mymetadatapromise.promise; }
any suggestions make cleaner great. 1 thought had define promise in controller , have data service return breeze promise. thought clutter controller , not separate out concerns.
take @ new to$q
extension in breeze labs on github have been using pretty extensively effect.
we haven't documented yet comments explain how "install" , use it.
your maindataservice.getmetadata()
be:
return manager.metadatastore.fetchmetadata(servicename).to$q();
and subsequently intended:
maindataservice.getmetadata() .then(function() { enablecreatebutton(); });
you in land of $q
. angular $apply
enablecreatebutton automatically.
Comments
Post a Comment