2016-07-05 14 views
1

我試圖在我的應用程序中添加Angular UI Grid,下面介紹教程Tutorial: 101 Intro to UI-Grid並面臨以下問題。

首先,電網工程,我可以控制,只要我把它添加到項目中創建和綁定查看,但 (只需添加一個模塊,實際上並沒有使用它的任何地方),其工作攔截之前不再被解僱,更具體地說,它需要與ng-include查看模板加載(請參閱下面的代碼摘錄)。

編輯:請注意,ng-include的作品,它只是沒有通過攔截器,但作品沒有。

  • 角1.4.8
  • UI電網3.2.1
  • 的jQuery 2.2.0

我試了一下:

  1. 使用其他版本的角度,
  2. 嘗試帶有工廠的init攔截器,
  3. 初始化陣列中模塊的更改順序,
  4. 嘗試了其他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> 

角應用程序初始化:

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); 
       } 

      }; 
     }]); 
    } 
]); 
+0

在我的模塊初始化,我有ui.grid不ui-grid ...可以幫助嗎? –

+0

這是這裏的錯字,更新了Q. –

+0

你怎麼知道你的攔截器不工作?你有沒有嘗試添加一些斷點和調試? – Phil

回答

0

我把它從無到有,現在的工作。看起來我錯過了某處的一些小配置錯字。顯然ui-grid不會干擾角度http攔截,所以結論是這是虛假警報。

相關問題