离子微调框未显示 [英] Ionic Spinner not showing up

查看:94
本文介绍了离子微调框未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用http请求填充了Ionic收集重复列表,但是我不想将所有内容直接加载到DOM中.因此,我只显示其中一些项目,并在向下滚动时添加其余项目.为此,我实现了无限滚动功能.当我到达页面底部时,它应该显示一个微调框,但不是.这些项目至少确实显示出来.

I fill a Ionic collection-repeat list with a http-request, but I don't want to load everything directly into the DOM. So I'm only displaying a few of the items and add the rest of them when you scroll down. For that I have implemented the infinite-scroll function. It should show a spinner, when I get to the bottom of the page but it doesn't. The items do show up at least.

这是代码:

HTML:

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

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href=" http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet">
    <link href="css/style.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>
  </head>
  <body ng-controller="MyCtrl">

    <ion-pane>
      <ion-header-bar class="bar-positive">
        <h1 class="title">Ionic Refresher testApp</h1>
      </ion-header-bar>
      <ion-content>
       <ion-refresher on-refresh="doRefresh()" spinner="bubbles"></ion-refresher>
      <ion-list>
        <ion-item class="item-thumbnail-left" collection-repeat="item in items | limitTo:numberOfItemsToDisplay">
        <img src="img/ionic.png" class="circle">
        <p>Link</p>
    <h2>{{item.id}}</h2>
    <h2>{{item.title}}</h2>
        </ion-item>
       <i class="icon ion-ios-arrow-right"></i>
        <ion-infinite-scroll
    on-infinite="addMoreItem()"
    distance="1%" spinner="bubbles">
  </ion-infinite-scroll>
      </ion-list>
      </ion-content>
    </ion-pane>
  </body>
</html>

App.js:

angular.module('ionicApp', ['ionic'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    if(window.cordova && window.cordova.plugins.Keyboard) {
      // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
      // for form inputs)
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);

      // Don't remove this line unless you know what you are doing. It stops the viewport
      // from snapping when text inputs are focused. Ionic handles this internally for
      // a much nicer keyboard experience.
      cordova.plugins.Keyboard.disableScroll(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
})

.factory('TweetService', function($http){
  var BASE_URL = "http://jsonplaceholder.typicode.com/posts";
  var items = [];



  return {
    GetFeed: function(){
      return $http.get(BASE_URL).then(function(response){
        items = response.data;
        return items;
      });
    },
    GetNewTweets: function(){
      return $http.get(BASE_URL).then(function(response){
        items = response.data;
        return items;
      });
    }
  }
})

.controller('MyCtrl', function($scope, $timeout, TweetService) {
  $scope.items = [];
  $scope.numberOfItemsToDisplay = 5;

  TweetService.GetFeed().then(function(items){
  $scope.items = items;
  });

   $scope.addMoreItem = function() {
        if ($scope.items.length > $scope.numberOfItemsToDisplay)
          $scope.numberOfItemsToDisplay += 5; // load 5 more items
        $scope.$broadcast('scroll.infiniteScrollComplete');
      };

  $scope.doRefresh = function() {
    TweetService.GetNewTweets().then(function(items){
      $scope.items = items;

      //Stop the ion-refresher from spinning
      $scope.$broadcast('scroll.refreshComplete');
    });
  };

});

推荐答案

不幸的是,它还没有解决.无限滚动还有另外一个问题

Unfortunately it's not solve yet. There are share one more problem with infinite-scrolling

https://论坛. ionicframework.com/t/infinite-scrolling-and-collection-repeat-spinner-not-shown/14358

这篇关于离子微调框未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆