2014-10-06 10 views
5

Angular 1.3.0 RC-2'den RC-3'e yükseltilmesinden bu yana ui-sref tarafından oluşturulan bağlantılarmdaki hash-işareti ortadan kalktı. Bağlantı tıklanabilir ve devlet aktarımları doğru bir şekilde gerçekleşir, ancak bağlantı adresini kopyalayıp tarayıcıya yapıştırırsam yanlış sayfaya gider. HTML5Mode kullanmak istemiyorum.URL'de hash oluşturmayan Ui-sref (Açısal 1.3.0-rc.3)

1.3.0-rc.2

<!DOCTYPE html> 
    <html> 

     <head> 
     <link rel="stylesheet" href="style.css"> 
     </head> 

     <body ng-app="myApp"> 

     <div ui-view></div> 
     <script src="https://code.angularjs.org/1.3.0-rc.2/angular.js"></script> 
     <script src="https://rawgit.com/angular-ui/ui-router/0.2.11/release/angular-ui-router.js"></script> 
     <script> 
      angular.module('myApp', ['ui.router']) 
      .config(function($stateProvider, $urlRouterProvider, $locationProvider) { 


      $urlRouterProvider.otherwise('/foo'); 

      $stateProvider.state('foo', { 
       url: '/foo', 
       template: 'This is foo <a ui-sref="foo.bar">Go to bar</a><div ui-view></div>' 
      }) 
      .state('foo.bar', { 
       url: '/bar', 
       template: 'This is bar' 
      }) 

      $locationProvider.html5Mode(false); 
      //$locationProvider.html5Mode({ enabled: false }) 
      }); 
     </script> 

     </body> 

    </html> 

Plunkr demonstrating working example

1.3.0-rc.4

<!DOCTYPE html> 
    <html> 

     <head> 
     <link rel="stylesheet" href="style.css"> 
     </head> 

     <body ng-app="myApp"> 

     <div ui-view></div> 
     <script src="https://code.angularjs.org/1.3.0-rc.4/angular.js"></script> 
     <script src="https://rawgit.com/angular-ui/ui-router/0.2.11/release/angular-ui-router.js"></script> 
     <script> 
      angular.module('myApp', ['ui.router']) 
      .config(function($stateProvider, $urlRouterProvider, $locationProvider) { 


      $urlRouterProvider.otherwise('/foo'); 

      $stateProvider.state('foo', { 
       url: '/foo', 
       template: 'This is foo <a ui-sref="foo.bar">Go to bar</a><div ui-view></div>' 
      }) 
      .state('foo.bar', { 
       url: '/bar', 
       template: 'This is bar' 
      }) 

      //$locationProvider.html5Mode(false); 
      $locationProvider.html5Mode({ enabled: false }) 
      }); 
     </script> 

     </body> 

    </html> 

Plunkr demonstrating the problem

ben yanlış bir şey yapıyor, ya da muyum ui yönlendirici Angular en son sürüm adayı ile uyumlu değil?

cevap

6

Bu bilinen bir sorun. master'da düzeltildi. https://github.com/angular-ui/ui-router/issues/1397

Açısal 1.3, HTML5 modu API'sini değiştirdi ve UI-Router, ya API'yi desteklemeli. Hızlı bir onay işareti olan

+0

. heh –

+0

0.2.12 öncesi bir sürüm yayınladım: http://bit.ly/UIR-0212pre1 –