V
V
viktorulyushev2017-09-25 09:47:39
JavaScript
viktorulyushev, 2017-09-25 09:47:39

Keep track of the value received by the class and add the class?

There is such a code, in the variable @ShoppingCartService.CurrentWishlist.Count I get a value, for example 0 and 1 depending on the button being pressed, I need to monitor this value and if it becomes greater than 0, then add some class for the span, I tried to do this

class="@(@ShoppingCartService.CurrentWishlist.Count > 0  ? " products-view-tile-element-hidden" : "")"

but it doesn't work dynamically, how to do it with a script?
<div class="whish-list">
                <a href="@Url.AbsoluteRouteUrl("WishList")">
                    <span class="@(@ShoppingCartService.CurrentWishlist.Count > 0  ? " products-view-tile-element-hidden" : "")"  data-wishlist-count data-start-count="@ShoppingCartService.CurrentWishlist.Count" data-ng-bind="wishlistCount.countObj.count">
                        @ShoppingCartService.CurrentWishlist.Count
                    </span>
                </a>
            </div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2017-09-25
@yarosroman

Something is not clear, do you have a mixture of ASP and Angular? Are your templates generated on the server?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question