我有一个我写的应用名称作为参数的应用程序,但是当我在加载其他名称后点击链接时,页面什么都不做,尽管通过URL传递了新的参数。我想象Angular DOM没有重新加载,因为它在“技术上”是同一个网页。但是,我需要它来加载更新的数据。
这是填充链接列表的Angular JS / HTML:
<li ng-repeat="internalRep in internalReps "><a href="repweekly.html#!?rep={{internalRep.such}}">{{internalRep.such}}</a></li>
现在,当您处于一个完全不同的页面并单击其中一个链接时,它可以完美地运行。但是,如果您已经在 ./ repweekly.html#!? rep = REP1 上,请点击链接转到 ./ repweekly.html#!? rep = REP5 它将更改URL栏中的URL,但不会发生任何其他情况。如果您随后单击刷新按钮,则会加载正确的数据。
我将代码更改为:
<li ng-repeat="internalRep in internalReps "><a ng-href="./repweekly.html#!?rep={{internalRep.such}}">{{internalRep.such}}</a>
再次,当地址栏中的URL发生更改时,页面不会重新加载以显示更新的代表。
答案 0 :(得分:0)
好的,这就是我最终做的事情 -
该链接保持为Josué建议的一个例外 - 我向其添加了ng-click指令(ng-click =“reloadRep()”):
<li ng-repeat="internalRep in internalReps"><a ng-href="repweekly.html#?rep={{internalRep.such}}" ng-click="reloadRep()">{{internalRep.such}}</a></li>
然后我将$ window注入控制器:
angularApp.controller('mainController', ["$scope", "$http", "$filter", "$location", "$window", function ($scope, $http, $filter, $location, $window) {...
最后我创建了在调用ng-click时运行的函数:
$scope.reloadRep = function () {
$window.location.reload();
};