我正在尝试在$cordovaActionSheet plugin的buttonLabels中添加图标,但是它不起作用。我努力了
var options = {
title: 'Share',
buttonLabels: ['<i class="ion-social-facebook"></i> Share via Facebook', '<i class="ion-social-twitter"></i> Share via Twitter'],
};
但它按原样打印标签。如何在按钮标签中显示图标?
最佳答案
我看到您也标记了ionic-framework
。如果使用的是Ionic
,则可以使用$ionicActionSheet
代替$cordovaActionSheet
。请参见this doc。
使用$ionicActionSheet
可以毫无问题地添加图像:
angular.module('mySuperApp', ['ionic'])
.controller(function($scope, $ionicActionSheet, $timeout) {
// Triggered on a button click, or some other target
$scope.show = function() {
// Show the action sheet
var hideSheet = $ionicActionSheet.show({
buttons: [
{ text: '<i class="ion-social-facebook"></i> Share via Facebook' },
{ text: '<b>Share</b> This' },
{ text: 'Move' }
],
destructiveText: 'Delete',
titleText: 'Modify your album',
cancelText: 'Cancel',
cancel: function() {
// add cancel code..
},
buttonClicked: function(index) {
return true;
}
});
// For example's sake, hide the sheet after two seconds
$timeout(function() {
hideSheet();
}, 2000);
};
});