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

2019-09-07 16:47发布

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.

2条回答
看我几分像从前
2楼-- · 2019-09-07 17:26

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>
查看更多
戒情不戒烟
3楼-- · 2019-09-07 17:32

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>
查看更多
登录 后发表回答