天天看点

ionic下拉刷新

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <link href="ionic.css" rel="stylesheet"/>
    <script type="text/javascript" src="ionic.bundle.js"></script>
    <title>下拉刷新</title>
    <script type="text/javascript">
        var app = angular.module("Demo1App", ["ionic"]);
        app.controller("Demo1Ctrl", function ($scope, $http) {
            $scope.items = [
                {
                    name: "AAAAAA"
                },
                {
                    name: "BBBBBB"
                },
                {
                    name: "CCCCCC"
                }
            ];

            $scope.doRefresh = function () {
                $http.get("item.json").success(function (data, status) {       
//注意改为自己本站的地址,不然会有跨域问题      
// 成功之后执行的代码 $scope.items = data; }).error(function (data, status) { // 失败之后执行的代码 console.log(status); }).finally(function () { // 无论成功或失败之后执行的代码 $scope.$broadcast('scroll.refreshComplete'); }); }; }); </script></head><body ng-app="Demo1App"><ion-pane ng-controller="Demo1Ctrl"> <ion-content> <ion-refresher pulling-text="下拉刷新" on-refresh="doRefresh()"></ion-refresher> <ion-list> <ion-item ng-repeat="item in items" ng-bind="item.name"></ion-item> </ion-list> </ion-content></ion-pane></body></html>