目前我正在做这样的事情
link.on('click', function () {
if (link.attr('href') !== $route.current.originalPath)
return;
$route.reload();
});
我不了解副作用,但我想可能会有一些副作用。
是否有更直接的方法来处理ngRoute中的问题,例如通过$location
?
更新应用程序以使用它时,在UI Router中执行相同操作的方法是什么?
您的代码可以得到tranformed以下变化$route.reload()
来$state.reload()
代码
link.on('click', function () {
if (link.attr('href') !== $route.current.originalPath)
return;
//though this will not reload the controller content
$state.reload(); //will force to reload state..
$scope.$apply(); //needed here to tell angular js to run digest cycle.
});
从git-hub发出的问题似乎是$state.reload()
重新加载状态,但控制器不会重新实例化。为此,您需要使用以下代码代替$state.reload()
$state.transitionTo('tab.locations', $state.$current.params, {
reload: true, inherit: true, notify: true
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句