给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>
推荐问题