2013-10-09 77 views
0

我有一个奇怪的问题。如果我在浏览器中手动浏览到http://mysite.com:1540/#/5,角路由被调用并且一切正常。但是,当我点击浏览器中URL更改下方的任何链接时,但路由不会被触发。我已经证实了这一点,因为我有一个警告函数,当一个新的ID被放置在URL中时被调用。我将不胜感激任何帮助。Angular JS问题刷新页面

预先感谢您。

> //this is the route $routeProvider.when("/:id", { 
>  controller: "topicsControllerByPage", 
>  templateUrl: "/templates/topicsView.html" }); 
> 
> 
> var topicsControllerByPage = ["$scope", "$http", 
> "dataService","$routeParams", function ($scope, $http, dataService, 
> $routeParams) { 
>  $scope.data = dataService; 
>  $scope.isBusy = false; 
> 
> 
>  if (dataService.isReady() == false) { 
>   $scope.isBusy = true; 
> 
>   dataService.getTopicsByPage($routeParams.id) 
>    .then(function() { 
>     // success 
> 
>    }, 
>    function() { 
>     // error 
>     alert("could not load topics"); 
>    }) 
>    .then(function() { 
>     $scope.isBusy = false; 
>    }); 
>  } }]; var newTopicController = ["$scope", "$http", "$window", "dataService", function ($scope, $http, $window, dataService) { 
>  $scope.newTopic = {}; 
> 
>  $scope.save = function() { 
>   //alert($scope.newTopic.title); 
>   //alert($scope.newTopic.filepath); 
>  dataService.addTopic($scope.newTopic) 
>   .then(function() { 
>   // success 
>   $window.location = "#/"; 
>   }, 
>   function() { 
>   // error 
>   alert("could not save the new topic"); 
>   }); 
> 
>  }; }]; 




<div class="pagination pagination-centered"> 
       <ul> 
        <li class=" disabled"><a href="#">« </a></li> 
        <li class="active"><a href="#">1</a></li> 
        <li></li> 

        <li><a href="#/2">2</a></li> 
        <li></li> 
        <li><a href="#/3">3</a></li> 
        <li></li> 
        <li><a href="#/4">4</a></li> 
        <li></li> 
        <li><a href="#/5">5</a></li> 
        <li></li>      
        <li><a href="#/2"> »</a></li> 
       </ul> 
      </div> 
+0

你使用'ng-view'吗? –

回答

0

我删除if(dataService.isReady()== false)并且代码现在可以工作。