即使所有 $scope 变量都在一个对象中,ng-click 也无法在 ion-scroll 中工作

ng-click not working in ion-scroll even when all $scope variables are in an object

我创建了一个plnkr for this problem. I can't get the ng-click to work on this page. I thought I could solve this issue, with the answers I got from this question:

但是即使我在对象中使用了所有 $scope 变量,函数也不会执行。

试试这个:

<ion-scroll direction="x">
    <div class="icon app-symbol" ng-repeat="image in data.default_images" >
        <a ng-click="data.setCurrentImage(image)"> 
            <img ng-src="{{ image.src }}" >
        </a>
    </div>
</ion-scroll>

出于某种原因(我不是 Ionic 开发人员),ionic 使 <label> 吞下所有点击事件。所以你需要将该标签更改为其他任何内容或将 ng-repeat 放在它外面。我在 plunker

写了一个例子
<div ng-click="foo()">This one works</div>
<label>
  <div ng-click="foo()">This one doesn't</div>
</label>