Search code examples
angularjscordovaionic-frameworkvisual-studio-cordova

ionic content not scrolling


I have gone through many answers, but nothing worked for me. I have a simple .html file and ionic content just does not scroll.

<!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></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">
    -->
    <script src="js/platformOverrides.js"></script>

    <script src="scripts/angular-resource.min.js"></script>
    <!-- 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>

    <script src="scripts/jquery.min.js"></script>
    <script src="scripts/angular-sanitize.min.js"></script>
    <script src="scripts/angular-ui-router.js"></script>
    <script src="scripts/angular-resource.js"></script>
    <script src="scripts/lodash.min.js"></script>

    <script src="js/app.js"></script>
    <script src="js/appController.js"></script>
</head>
<body ng-app="app" ng-controller="appController">
    <ion-pane>
        <ion-header-bar class="bar-stable">
            <h1 class="title">Ionic Blank Starter</h1>
        </ion-header-bar>
        <ion-view>
            <ion-content scroll="true">
                <div class="scroll">
                    <a ng-repeat="item in items" class="item" href="#">
                        <h2>{{item.name}}</h2>
                    </a>
                </div>
            </ion-content>
        </ion-view>
    </ion-pane>
</body>
</html>

Above, $scope.items is being fetched from some webservice. Everything renders fine but it just does not scroll. I am using Visual studio 'Ionic Blank Template' if that matters. I have configured Cordova correctly and rest all solutions just work fine.


Solution

  • Remove the class="scroll" from the div container, scroll="true" from ion-content and add overflow-scroll="true" . The required classes will be added by ionic on the elements. You don't need to add that explicitly

    <ion-view>
       <ion-content overflow-scroll="true">
            <div class="list">
                <a ng-repeat="item in items" class="item" href="#">
                    <h2>{{item.name}}</h2>
                </a>
            </div>
        </ion-content>
    </ion-view>
    

    Update: The codepen showing the scrollable list in chrome simulator: http://codepen.io/addi90/full/RaOegM/

    Ionic scrollable list