给class属性值添加后缀

<div class="details" ng-repeat="shopInfo in shops.shopInfos" ng-touchstart="addClass()" ng-touchend="" ng-touchmove="removeClass()">
            <span class="detai-pic"><img ng-src="{{fn.getShopIcon(shopInfo)}}" /></span>
            <span class="detai-name">{{shopInfo.shopName}}</span>
</div>

上述代码所示,是一个循环,用的是angularjs的touch事件,当点击时,我要在class=“detail”变成“detail_on”,怎么做改变,注意它是一个循环的div。
阅读 3.8k
1 个回答

那这样吧:

<div ng-class="{details: !shopInfo.touched, detail_on: shopInfo.touched}" ng-repeat="shopInfo in shops.shopInfos" ng-touchstart="shopInfo.touched = true" ng-touchend="" ng-touchmove="shopInfo.touched = false">
            <span class="detai-pic"><img ng-src="{{fn.getShopIcon(shopInfo)}}" /></span>
            <span class="detai-name">{{shopInfo.shopName}}</span>
</div>
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题