2017-10-22 152 views
0

當試圖使用IE11進行導航時,鏈接不能與狀態(如url: '/main-category/:id')一起使用,但「父」狀態url: '/:main-category/'正常工作。這些不是真正的嵌套或父子,因爲除導航外,它們實際上並不共享任何常見的視圖/ html模板。是這些ui-sref狀態ie11友好

我發現this meta tag建議和這IE events建議,但似乎都沒有提供解決方案,爲什麼我的導航欄和來自另一個州的鏈接不起作用。

這裏是一個live site沒有minify,測試比較IE11 &所有其他瀏覽器。

那麼,這些路線是否正確設置?

router.js

angular.module('app_litsco') 
    .config(['$stateProvider', '$urlRouterProvider', '$locationProvider', function ($stateProvider, $urlRouterProvider, $locationProvider) { 

     $urlRouterProvider.otherwise('/'); 

     $stateProvider 
      .state('home', { //this state works 
       url: '/', 
       templateUrl: 'html/home.html', 
       controller: 'controller_home', 
      }) 
      .state('product_streamline', { //this state DOES NOT work 
       url: '/streamline_metal_panels/:id', 
       templateUrl: 'html/template_product.html', 
       controller: 'controller_prods', 
      }) 
      .state('streamline_panels', { //this state works 
       url: '/:cat', 
       templateUrl: 'html/template_productlist.html', 
       controller: 'controller_productlist', 
      }) 

     $locationProvider.html5Mode(true); 
    }]); 

的index.html

例子的NavBar部分

<li class="link"> 
    <!-- Main Category link --> 
    <a data-activates="streamline-panel-dropdown" class="blue-text text-darken-4 product-link" ui-sref="streamline_panels({ cat: 'streamline_metal_panels' })">STREAMLINE METAL PANELS</a> 
    <div id="streamline-panel-dropdown" class="dropdown-content dropdown-full full"> 
     <div class="container dropdown-container flex-row-around-center"> 
      <div class="col sm12 m3 text-center dropdown-item"> 
    <!-- Sub-Category links --> 
       <a ui-sref="product_streamline({ id: 'classic_cr' })" class="product-link">Classic CR</a> 
      </div> 
      <div class="col sm12 m3 text-center dropdown-item"> 
       <a ui-sref="product_streamline({ id: 'omniwall_md' })" class="product-link">Omniwall MD</a> 
      </div> 
      <div class="col sm12 m3 text-center dropdown-item"> 
       <a ui-sref="product_streamline({ id: 'omniwall_cl' })" class="product-link">Omniwall CL</a> 
      </div> 
     </div> 
    </div> 
</li> 

回答

0

product_streamline狀態使用Array.find()的決心,這IE不支持。

 .state('product_streamline', { 
      url: '/streamline_metal_panels/:id', 
      templateUrl: 'html/template_product.html', 
      controller: 'controller_prods', 
      resolve: { 
       product: ['factory_litsco', '$stateParams', function (factory_litsco, $stateParams) { 
        var productIdObj = factory_litsco.find(function (obj) { 
         if (obj.id === $stateParams.id) { 
          return obj; 
         } 
        }); 
        return productIdObj; 
       }], 
       $title: ['product', function (product) { 
        return product.productName; 
       }] 
      } 
     }) 

爲了檢測這些類型的錯誤,添加一個處理$stateChangeError如:

angular.element(document.getElementsByTagName('body')[0]).scope().$on('$stateChangeError', function() { console.log("Error", arguments) })

+0

感謝這個好找;) –