简体   繁体   English

href中的AngularJS重新加载页面

[英]AngularJS reload page in href

i want to reload when clicking the href. 我想在单击href时重新加载。

<li><a ng-href="#/detailedView">DetailedView</a></li>

so i have added the below method in controller js. 所以我在控制器js中添加了以下方法。

$scope.reloadRoute = function() {
$state.reload();
}

and modified the href like below, but still its not reloading. 并按如下所示修改了href,但仍未重新加载。

<li><a ng-click="reloadRoute()" ng-href="#/detailedView">DetailedView</a></li>

i have tried $route.reload(); 我已经尝试过$route.reload(); as well, but the page is not getting refreshed while clicking the href 同样,但是单击href时页面没有刷新

Looks like you are using ui-router? 看起来您在使用ui-router?

In that case you can use a statement like this from the html: 在这种情况下,您可以从html使用如下语句:

<a ui-sref="<state-name-for-detailed-view>" ui-sref-opts="{reload: true}">DetailedView</a>

And that should reload the page. 那应该重新加载页面。 More info here 更多信息在这里

There are some other options on this SO page 该SO页上还有其他一些选项

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM