单击刚打开时如何强制启动控制器 link

How to force start controller when click on just opened link

当我尝试转到刚刚打开的 link 时,$routeProvider 没有再次启动 controller

示例:

如何在点击刚打开link时强制启动controller? 或者 运行 点击时所有 link 的初始代码(但在此之后转到目标 link)?

你能post举个例子吗?根据您配置 $stateProvider 的方式,可能是问题所在。

使用$route.reload();

来自文档:

$route.reload();

Causes $route service to reload the current route even if $location hasn't changed.

As a result of that, ngView creates new scope and reinstantiates the controller.

-- AngularJS $route API Reference - reload