利用ionic实现下拉刷新


<html>
    <head>
        <meta charset="utf-8" />
        <title>ionictitle>

        
        <script src="js/ionic.bundle.min.js" type="text/javascript" charset="utf-8">script>
        <link rel="stylesheet" type="text/css" href="css/ionic.css"/>
        
    head>

    <body ng-app="myApp" ng-controller="myCtrl">

        <ion-header-bar class="bar-calm">
            <h1 class="title">下拉刷新h1>
        ion-header-bar>
        <ion-content>
            
            <ion-refresher pulling-text="松手刷新..." on-refresh = "doRefresh()" pulling-icon="img/arrow-down-c.png">

            ion-refresher>
            <ul class="list">
                <li class="item" ng-repeat="good in goods">{{good.gname}}li>
            ul>
        ion-content>

        

        <script type="text/javascript">
            //创建模块
            var mod = angular.module("myApp",["ionic"]);//[]里面的是需要注入的对象。两个:ngRoute /ionic
            //创建控制器
            mod.controller("myCtrl",function($scope,$http){

                //定义数组、也就是model数据
                $scope.goods=[{"gname":"秋裤"},{"gname":"羽绒服"}];
                //刷新的方法
                $scope.doRefresh=function(){
                    //请求网络,加载数据
                    $http.get("data.json").then(function(req){
                        //取得数据 ,req将数据封装到data属性里面了
                        var d = req.data;
                        //将一个集合整个加入另外一个集合contact()
//                      $scope.goods= $scope.goods.contact(d);
                        for (var i =0;i//结束刷新
                        $scope.$broadcast("scroll.refreshComplete");
                    },function(req){
                        alert("失败");
                    });
//                  .finally(function(){
//                      
//                  });

                }
            });
        script>
    body>
html>

你可能感兴趣的:(前端h5,css3,javascript...)