0

s 也是一个非常大的图书馆,我无法确定拦截点在哪里……有人有什么建议吗???谢谢你

4

2 回答 2

1

您已正确识别问题。现在 Breeze 确实期望 XHR 并且 angular 不会返回一个。我们有一个功能请求,它应该在接下来的几个版本之一中实现,以允许您将 Angular 的 http 服务包装为“微风”ajax 适配器。

不过现在:(其余部分是推测性的和未经测试的,但总体思路应该可行),您最好的选择可能是创建现有“ajax”适配器的修饰版本。即类似的东西。

 var origAjaxCtor = breeze.config.getAdapter("ajax");
 var newAjaxCtor = function () {
    this.name = "newAjax";
    this._origAjaxCtor = new origAjaxCtor();
 }
 newAjaxCtor.prototype = new oldAjaxCtor(); // to delegate all other methods
 newAjaxCtor.prototype.ajax = function (settings) {
    settings.success = function((data, textStatus, XHR) {
       // call the original success code
       settings.success(data, textStatus, XHR);
       // followed by your custom scope code.
       // ...do your scope apply here...    
    });
    // perform the actual ajax call - this will call your custom success method from above.
    this._origAjaxCtor.ajax(settings);
 }
 // register the new adapter
 breeze.config.registerAdapter("ajax", newAjaxCtor);
 // make this adapter the default
 breeze.config.initializeAdapterInstance("ajax", "newAjax", true);
于 2013-06-07T00:58:26.420 回答
0

从 Breeze 1.4.4 开始,我们现在支持使用 $http 的 angular ajax 适配器。有关详细信息,请参阅 1.4.4 发行说明。

对于您的具体问题,如果您使用 angular ajax 适配器的 setHttp 方法,您可以让 Breeze 在内部使用您的 $http 实例。

于 2013-10-15T20:52:49.287 回答