【问题标题】:angularjs: best way to force certain link paths to reloadangularjs:强制某些链接路径重新加载的最佳方法
【发布时间】:2013-03-19 22:01:24
【问题描述】:

我希望能够捕获我网站中以“/@”开头的任何链接,并在完全重新加载浏览器时进行处理。

类似:

$locationProvider.html5Mode(true)
$routeProvider.when("/@:id",
  # window.location.href = [the link's url]
  # all others are handled by typical controller/view

我已经能够使用锚标记上的属性/指令来解决问题,但我想在 url 路由级别执行此操作。

【问题讨论】:

标签: html angularjs routes


【解决方案1】:

我不确定这是否是最佳解决方案,但您可以根据当前时间而不是“/@”代码设置参数

例如

<a href="/Customer/Edit/{{customer.id}}&refresh={{now}}">{{customer.Name}}</a>

在每个 $routeChangeSuccess 之后在 $rootScope 上设置“现在”

$rootScope.$on('$routeChangeSuccess', function (event, current, previous) {
$rootScope.now = Date.now();
});

这可能会有所改进,但它正在工作。

你也可以看看angularjs - refresh when clicked on link with actual url

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-31
    • 2012-03-02
    相关资源
    最近更新 更多