Pull to refresh isn't working


#1

Hi guys,
This is probably a very easy error but I’ve stuck on it for a while now. If anyone could help me out i would be very grateful!! Thank you, i’ll place the code below. The Http.get works fine because i’ve tested in on a button, it’s just when i paste the pull to refresh code it stops working.

Code HTML:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title>Announcement</title>

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/ionic.app.css" rel="stylesheet">
    -->

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>

    <!-- cordova script (this will be a 404 during development) -->
    <script src="cordova.js"></script>

    <!-- your app's js -->
    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
    <script src="js/services.js"></script>
  </head>
  <body ng-app="Announcement">
    <ion-view view-title="Announcements">
      <ion-pane>
         <ion-header-bar class="bar-positive">
          <h1 class="title">Pull To Refresh</h1>
        </ion-header-bar>
        <ion-view view-title="Announcements">
        <ion-content>
          <ion-refresher on-refresh="doRefresh()">

          </ion-refresher>
          <ion-list>
            <ion-item ng-repeat="item in items" ng-click="getData()">

            <div class="list card">
              <div class="item item-divider">{{announcement_name}} - {{date}}</div>
              <div class="item item-body">
                <div>
                  {{message}}
                </div>
            </ion-item>
          </ion-list>
        </ion-content>
        </ion-view>
  </body>
</html>

Javascript:

.controller('Controller', function($scope, $http) {
    $scope.items = [1,2,3];
    $scope.doRefresh = function() {
        $http.get("http://www.wikicode.co.uk/announcement.json", { params: { "name": "value1", "date": "value2", "message": "value3"} })
            .success(function(data) {
                $scope.announcement_name = data.announcement_name;
                $scope.date = data.date;
                $scope.message = data.message;
            })
            .finally(function() {
           // Stop the ion-refresher from spinning
           $scope.$broadcast('scroll.refreshComplete');
         });
         myApp.error(function(newItems) {
        alert("something went wrong");
      })
      };
    });

#2

What’s “not working” exactly? It’s easier if you create a Codepen with your code.


#3

It should load the data from the url but doesn’t. The HTTP get is working because i tried it with a button but once i added the pull to refresh it stopped working. Any idea why?


#4

what is this doing? A simple codePen will help resolve your issue :smile:


#6

If it fails that will be called and codePen won’t work. I need more than 1 html and css page to get the same display. Can codePen do that?