在滑动时,按钮不会显示在离子状态

时间:2014-04-16 21:39:30

标签: angularjs ionic-framework

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

2 个答案:

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

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

答案 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>