angularjs - Breeze rejectChanges() doesn't return a promise? -
with following code:
function cancelchanges() { if (datacontext.manager.haschanges()) { return datacontext.manager.rejectchanges(); } else { console.log("no changes save"); } } if call this:
cancelchanges() .then(function () { console.log("changes cancelled"); }) i "object has no method 'then'". if use savechanges, works. problem else statement not returning i'll error .then , .fail calls... how can fixed use promises?
you can create promise of own using $q service in angular.
function cancelchanges() { var deferred = $q.defer(); if (datacontext.manager.haschanges()) { datacontext.manager.rejectchanges(); deferred.resolve("changes cancelled"); } else { deferred.reject("no changes save"); } return deferred.promise; } cancelchanges() .then(function (result) { console.log(result); })
Comments
Post a Comment