ng-click not working in ion-scroll even when all $

2019-09-07 17:34发布

问题:

I have created a 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: Why do I need $parent to enable the function in ng-click when using ion-scroll?

But even when I use all the $scope variables in an object the function is not executed.

回答1:

For some kind of reason (I am not an Ionic dev), ionic makes the <label> swallow all the click events. So you need to change that label to anything else or put the ng-repeat outside it. I wrote an example at plunker

<div ng-click="foo()">This one works</div>
<label>
  <div ng-click="foo()">This one doesn't</div>
</label>


回答2:

Try this:

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