這篇文章將為大家詳細講解有關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">
<h2 class="title">我是標題</h2>
</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">
<h2 class="title">我是底部</h2>
<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>關于“ionic怎么實現底部分享功能”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。