本文實例為大家分享了ionic底部分享功能的具體代碼,供大家參考,具體內容如下
<!DOCTYPE html><html ng-app="myApp"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <link rel="stylesheet" href="js/lib/ionic1/css/ionic.min.css" rel="external nofollow" > <script src="js/lib/ionic1/js/ionic.bundle.min.js"></script> <title>Title</title></head><body ng-controller="myCtrl"><!--頁面頭部--><ion-header-bar class="bar-royal"> <h1 class="title">我是標題</h1></ion-header-bar><!--內容--><ion-content> <!-- 1.添加下拉刷新的組件 --> <ion-refresher pulling-text="正在刷新頁面數據..." on-refresh="doRefresh()"> </ion-refresher> <!--ng-repent 渲染內容--> <ul class="list"> <li ng-repeat="g in goodses track by $index"> <span ng-bind="g"></span> </li> </ul> <!-- 1.添加上拉刷新的組件 --> <ion-infinite-scroll on-infinite="loadMore()" distance="3%"> </ion-infinite-scroll></ion-content><!--頁面底部--><ion-footer-bar class="bar-royal"> <h1 class="title">我是底部</h1> <button class="button button-clear" ng-click="share()"><i class="icon ion-share"></i></button></ion-footer-bar><script> var app=angular.module("myApp",["ionic"]); app.controller("myCtrl",["$scope","$ionicActionSheet",function ($scope,$ionicActionSheet) { $scope.goodses=[]; for(var i=0;i<50;i++){ $scope.goodses.push(i+"我是首頁展示") } //下拉刷新 $scope.doRefresh=function () { $scope.goodses=[]; //下拉載入數據 for(var i=0;i<50;i++){ $scope.goodses.push(i+"我是下拉載入****") } $scope.$broadcast("scroll.refreshComplete"); } //上拉刷新 $scope.loadMore=function () { //上拉載入數據 for(var i=0;i<50;i++){ $scope.goodses.push(i+"我是上拉載入++++") } $scope.$broadcast("scroll.infiniteScrollComplete"); } //分享// Action Sheet :(操作表)//表示一個從下向上滑動出現的對話框// 使用的時候,需要注入一個$ionicActionSheet服務// 服務有一個函數show()用于根據指定的選項展示這個對話框// 函數內必須用return true;進行返回,不然對話框不能關閉 $scope.share=function () { $ionicActionSheet.show({ buttons: [ { text: '<b>分享</b> 微信' }, { text: '<b>分享</b>QQ ' }, ], destructiveText: '刪除', titleText: '分享', cancelText: '關閉', buttonClicked: function(index) { return true;//必須 }, destructiveButtonClicked:function () { console.log("刪除按鈕被點擊了****"); return true;//必須 } }); } }])</script></html>以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。
新聞熱點
疑難解答