1

在 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>
4

2 回答 2

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);
};

http://plnkr.co/edit/isubGyXN3FEy5hNIuUlR?p=preview

于 2014-04-16T22:51:16.410 回答
2

在 1.0.0-beta.1 中添加 can-swipe="true" option-buttons="itemButtons"到父元素似乎为我解决了这个问题

<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>
于 2014-04-18T13:03:38.810 回答