Angular $httpProvider拦截器停止工作'添加"UI网格"到应用程序
Angular $httpProvider interceptors stopped working for 'ng-include' after adding "UI Grid" to the app
我正在尝试将Angular UI Grid添加到我的应用程序中,下面是教程教程:101介绍UI-Grid,并面临以下问题。
首先,网格工作,我可以在控制器中创建它并绑定到视图,但是一旦我将它添加到项目中(只是作为一个模块添加,而不是实际使用它)以前工作的拦截器不再被触发,更具体地说,它需要用ng-include加载视图模板(见下面的一些代码摘录)。编辑:请注意ng-include工作,它只是不通过拦截器,但工作,因为没有。
- 角1.4.8 UI Grid 3.2.1jQuery 2.2.0
What I tried:
- 使用其他Angular版本时,
- 修改init数组中模块的顺序,
- 尝试其他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拦截,所以结论是它是假警报。
相关文章:
- Node.js服务器问题-已添加“/"在浏览器中查找文件时
- 改变“;onClick"这个jQuery的操作从清除输入文本改为将输入文本添加到下面的列表中
- 我正在使用php includes来构建一个多页面网站.使用jquery,我将如何添加一个类"活动的”;添加到
- jQuery脚本,它搜索现有的查询参数并且不添加“"如果存在
- 添加前缀“#"到数组中的某些字符串值
- JS/JQuery:动态添加"图案“;以及“;标题“;属性以形成输入
- "未捕获的类型错误:未定义的不是函数“;当向输入字段添加值时
- 将元素添加到javascript中"字典“;大堆
- ExtJS::如何添加特定的"specialkey事件”;表示逗号到数字字段
- 添加“<strong>"到某个单词使用handlers.js
- 如何在Wordpress文件中添加自定义javascript代码"single.php”;
- 如何为jQuery.append($(<option/>",{..})的每个三元大小写添加超过1个
- window.open()添加一个rel="nofollow”;属性
- "添加到手表“;铬键盘快捷键
- "更改“;添加要选择的选项时正在激发
- "这个“;当我向事件处理程序函数添加参数时会发生更改
- 添加“-"每个单词-javascript
- "添加到购物车”;按钮不'由于ReferenceError,无法工作
- 有没有一种简单的方法来转换“;字体"style属性添加到其中的每一个'他的个人风格
- 为什么我的动画"重放的“;当通过innerHTML添加元素时