[英]Angular JS Issue refreshing page
I have a strange problem. 我有一个奇怪的问题。 If I manually browse to http://mysite.com:1540/#/5 in the browser the angular route gets called and everything works fine.
如果我在浏览器中手动浏览到http://mysite.com:1540/#/5 ,则会调用角度路由,并且一切正常。 However, when I click on any of the links below the url changes in the browser, but the route doesn't get triggered.
但是,当我单击浏览器中url下方的任何链接时,浏览器都会更改,但不会触发该路由。 I've confirmed this because I have an alert on the function that gets called when a new id is placed in the url.
我已经确认了这一点,因为在将新ID放置在url中时,我会收到有关该函数调用的警报。 I would appreciate any help on this.
我将不胜感激。
Thank you in advance. 先感谢您。
> //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>
我删除了if(dataService.isReady()== false),现在代码可以正常工作了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.