Add a refresh on a button


#1

hi,
I look the tutorial for doing a refresh of a screen into my app, so i look ion-refresh function, but is there a way to attribute this function to a button (an a href tag) else the ion-refresh tool?

for example when i push i want that the screen does the refresh
is possible?
thanks!!


#2

I edited this codepen to refresh when a button is pressed

  <button class="button button-clear" ng-click="doRefresh()">
   Push to Refresh
  </button>

“doRefresh()” is the function you will be calling.


#3

I do in this way

  <ion-content>
    <ion-refresher on-refresh="remMedia()">
    </ion-refresher>
    <div class="row">
      <div class="col">
        <ion-scroll direction="x" style="height:200px; min-height: 200px; overflow: scroll; white-space: nowrap;">
          <img ng-repeat="image in images" ng-src="{{urlForImage(image)}}" style="height:200px; padding: 5px 5px 5px 5px;"/>
        </ion-scroll>
          <button class="button button-block button-large button-stable icon-left ion-plus" ng-click="addMedia()">Aggiungi immagine</button>
          <button class="button button-block button-large button-stable icon-left ion-minus" ng-click="remMedia()">Pulisci</button>

so when I push the second button I want that my screen is refreshed

  $scope.remMedia = function() {
    localStorage.clear();
    $timeout( function () {
      $scope.images;
      $scope.$broadcast('scroll.refreshComplete');
    }, 1000);
  }

this is the controller of the button, so the localStorage is clear regular and correctly but the page doesn’t refresh.

why?


#4

Well what exactly do you mean by “refresh”

I see

$scope.images: 

what exactly are you trying to accomplish with that?

Is it supposed to “refresh” with the new Image that was added?


#5

no, when i remove the images i want that the screen is reloaded or refreshes…