我有这个代码加载页面加载时的内容, 现在我想知道如何通过点击按钮来重新加载内容。 你能告诉我怎么用它做例子吗?Angularjs如何重新加载内容
Javascript代码:
.controller('InterNewsCtrl', function($scope, NewsService) {
$scope.events = [];
$scope.getData = function() {
NewsService.getAll().then(function (response) {
$scope.events = response;
}), function (error) {
}
};
$scope.getData(); // load initial content.
})
Html code:
<ons-toolbar fixed-style>
<div class="left">
<ons-back-button>Voltar</ons-back-button>
</div>
<div class="right">
<ons-toolbar-button><ons-icon icon="ion-android-refresh"></ons-icon></ons-toolbar-button>
</div>
<div class="center">Internacional</div>
</ons-toolbar>
重新加载整个页面? ''location.reload()' – dfsq
如果你想重载路由,那么应该使用'$ route.reload()' –
我的意思是重新加载内容 – jamil