我有以下HTML结构,但我希望我的刷新按钮刷新视图中的当前内容。 视图根据其路径构建不同的东西。 这是否可以在Angular中实现?
<header> <refresh button /> </header> <ng-view></ng-view> <footer></footer>I have the following HTML structure but I want my refresh button to refresh whatever is current in the view. The view builds different stuff depending on its route. Is this possible to achieve in Angular?
<header> <refresh button /> </header> <ng-view></ng-view> <footer></footer>最满意答案
您可以使用$route.reload方法。 考虑这个演示:
HTML:
<header> <button ng-click="refresh()">Refresh</button> </header>并在范围中定义刷新功能:
$scope.refresh = function() { $route.reload(); };演示: http : //plnkr.co/edit/mhhxmRacNIuET4u74Aty?p=preview
You can use $route.reload method. Consider this demo:
HTML:
<header> <button ng-click="refresh()">Refresh</button> </header>And you define refresh function in the scope:
$scope.refresh = function() { $route.reload(); };Demo: http://plnkr.co/edit/mhhxmRacNIuET4u74Aty?p=preview
修复了顶部的刷新,刷新控制器路由(Fixed refresh at top, refresh controllers routes on)我有以下HTML结构,但我希望我的刷新按钮刷新视图中的当前内容。 视图根据其路径构建不同的东西。 这是否可以在Angular中实现?
<header> <refresh button /> </header> <ng-view></ng-view> <footer></footer>I have the following HTML structure but I want my refresh button to refresh whatever is current in the view. The view builds different stuff depending on its route. Is this possible to achieve in Angular?
<header> <refresh button /> </header> <ng-view></ng-view> <footer></footer>最满意答案
您可以使用$route.reload方法。 考虑这个演示:
HTML:
<header> <button ng-click="refresh()">Refresh</button> </header>并在范围中定义刷新功能:
$scope.refresh = function() { $route.reload(); };演示: http : //plnkr.co/edit/mhhxmRacNIuET4u74Aty?p=preview
You can use $route.reload method. Consider this demo:
HTML:
<header> <button ng-click="refresh()">Refresh</button> </header>And you define refresh function in the scope:
$scope.refresh = function() { $route.reload(); };
发布评论