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

青春壹個敷衍的年華 提交于 2019-12-11 20:32:59

问题


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>


来源:https://stackoverflow.com/questions/30190624/ng-click-not-working-in-ion-scroll-even-when-all-scope-variables-are-in-an-obje

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!