Angular $httpProvider拦截器停止工作'添加"UI网格"到应用程序

Angular $httpProvider interceptors stopped working for 'ng-include' after adding "UI Grid" to the app

本文关键字:quot 添加 UI 网格 应用程序 停止工作 Angular httpProvider      更新时间:2023-09-26

我正在尝试将Angular UI Grid添加到我的应用程序中,下面是教程教程:101介绍UI-Grid,并面临以下问题。

首先,网格工作,我可以在控制器中创建它并绑定到视图,但是一旦我将它添加到项目中(只是作为一个模块添加,而不是实际使用它)以前工作的拦截器不再被触发,更具体地说,它需要用ng-include加载视图模板(见下面的一些代码摘录)。

编辑:请注意ng-include工作,它只是不通过拦截器,但工作,因为没有。

  • 角1.4.8
  • UI Grid 3.2.1jQuery 2.2.0

What I tried:

  1. 使用其他Angular版本时,
  2. 修改init数组中模块的顺序,
  3. 尝试其他jQuery版本

有没有人遇到过这样的问题,也许是其他模块?

HTML:

<body>
    <div ng-app="app">
        <div ng-controller="app.views.layout as vm">
            <div ng-include="'/App/Main/views/layout/header.cshtml'"></div>
            <div class="container">
                <div class="angular-animation-container row">
                    <div ui-view class="shuffle-animation col-xs-12"></div>
                </div>
            </div>
        </div>
    </div>
</body>

Angular应用初始化:

var app = angular.module('app', [
    'ngAnimate',
    'ngSanitize',
    'ui.router',
    'ui.bootstrap',
    'ui.jq',
    'ngTouch'
    'ui.grid'
    'abp',
]);

拦截器注册:

var abpModule = angular.module('abp', []);
abpModule.config([
    '$httpProvider', function ($httpProvider) {
        $httpProvider.interceptors.push(['$q', function ($q) {
            return {
                'request': function (config) {
                    if (endsWith(config.url, '.cshtml')) {
                        config.url = abp.appPath + 'AbpAppView/Load?viewUrl=' + config.url + '&_t=' + abp.pageLoadTime.getTime();
                    }
                    return config;
                },
                'response': function (response) {
                    if (!response.config || !response.config.abp || !response.data) {
                        return response;
                    }
                    var defer = $q.defer();
                    abp.ng.http.handleResponse(response, defer);
                    return defer.promise;
                },
                'responseError': function (ngError) {
                    var error = {
                        message: ngError.data || abp.ng.http.defaultError.message,
                        details: ngError.statusText || abp.ng.http.defaultError.details,
                        responseError: true
                    }
                    abp.ng.http.showError(error);
                    abp.ng.http.logError(error);
                    return $q.reject(ngError);
                }
            };
        }]);
    }
]);

我从头开始设置,现在它可以工作了。看起来我在某个地方漏掉了一个小的配置错别字。显然,ui-grid不会干扰angular http拦截,所以结论是它是假警报。