在Ionic框架内工作。我有一个非常简单的应用程序设置,无法在滑动时显示按钮:
//Swipable buttons don't work.
$scope.itemButtons = [
{
text: 'Edit',
type: 'Button',
onTap: function (item) {
alert('Edit Item');
}
},
{
text: 'Share',
type: 'Button',
onTap: function (item) {
alert('Share Item');
}
}
];
<ion-content>
<ion-list>
<ion-item ng-repeat="facility in facilities" item="item" can-swipe="true" option-buttons="itemButtons">
{{facility.name}}
</ion-item>
</ion-list>
</ion-content>
答案 0 :(得分:5)
您还有一个小错误 - 您应该设置item="facility"
,而不是item="item"
。但更重要的是,nightly-1.0.0-beta.1中没有此语法。新语法如下所示:
<ion-content>
<ion-list>
<ion-item ng-repeat="facility in facilities" item="facility" can-swipe="true">
Facility {{ facility .id }}
<ion-option-button class="button-assertive" ng-click="edit(facility)">
Edit
</ion-option-button>
<ion-option-button class="button-calm" ng-click="share(facility)">
Share
</ion-option-button>
</ion-item>
</ion-list>
</ion-content>
js:
$scope.edit = function(item) {
alert('Edit facility: ' + item.id);
};
$scope.share = function(item) {
alert('Share facility: ' + item.id);
};
答案 1 :(得分:2)
将can-swipe="true" option-buttons="itemButtons"
添加到父元素似乎在1.0.0-beta.1
<ion-list can-swipe="true" option-buttons="itemButtons">
<ion-item ng-repeat="facility in facilities" item="facility" ng-click="setFacilityId(facility.id)" href="#/app/facility">
{{facility}}
</ion-item>
</ion-list>