Я хочу создать перехватчик, который перехватит функцию сохранения Breezejs и хотел бы создать больше объектов сущности и добавить их в SaveBundle, прежде чем, наконец, BreezeController's SaveChanges
функционирует вместе с другими объектами.Добавьте еще объекты entitiy в SaveBundle of Breezejs при перехвате функции Save с помощью Angularjs
app.factory('changeHistoryInterceptor', ['$rootScope', '$q', '$timeout', function ($rootScope, $q, $timeout) {
var deferred = null, //promise to be returned
rConfig = null, //config to be returned
historySectionSet = false,
rDatacontext = null;
var Interceptor = {
request: function (config) {
deferred = $q.defer();
rConfig = config;
if (historySectionSet && config.url.contains('SaveChanges') && rDatacontext && rDatacontext.hasChanges()) {
$timeout(function() {
//I wish to create more entity objects and add them into SaveBundle on listening to this event
// so that it can be carried to server along with other objects
$rootScope.$broadcast('prepareHistory', { currentDate: new Date() });
}, 5);
return deferred.promise;
}
else
return config;
},
response: function (res) {
return res;
},
goThrough: function() {
// called from directive's controller on successfully creation of more entity objects
// how to access SaveBundle and add those created objects in SaveBundle?
if (deferred) {
historySectionSet = false;
deferred.resolve(rConfig);
deferred = null; rConfig = null;
}
},
setHistorySection: function (setSection, datacontext) {
historySectionSet = setSection;
rDatacontext = datacontext;
}
}
return Interceptor;
}]);
Есть ли какой-либо доступ к SaveBundle и поместить больше объектов в свойства данных, которые передаются на сервер?