Devesh Agrawal
Devesh Agrawal

Reputation: 9212

ng-if displaying both the div elements

There are 2 div tags, i want to display only 1 based on value of SelectedVariant.InCart.

Code is as follows:

<div ng-if="1==0">
    <a class="btn btn-success btn-md" ng-click="AddToCart(product.ProductID, SelectedVariant.VariantID)">Add to Cart &nbsp;
        <span class="glyphicon glyphicon-plus"></span> 
    </a>
</div>



<div ng-if="1==1">

    <a class="btn btn-default btn-xs" ng-click="PlusItem(product.ProductID, SelectedVariant.VariantID)">
        <span class="glyphicon glyphicon-plus"></span> 
    </a>

    <button type="button" class="btn btn-info disabled">{{3+2}} in cart</button>


    <a class="btn btn-default btn-xs" ng-click="MinusItem(product.ProductID, SelectedVariant.VariantID)">
        <span class="glyphicon glyphicon-minus"></span> 
    </a>
</div>  


        <a class="btn btn-default btn-xs" ng-click="MinusItem(product.ProductID, SelectedVariant.VariantID)">
            <span class="glyphicon glyphicon-minus"></span> 
        </a>
    </div>  

But it displaying both the div elements. Can someone help me what is the issue?

Upvotes: 2

Views: 107

Answers (1)

Kalhan.Toress
Kalhan.Toress

Reputation: 21901

your angular version is 1.0.7. directive ng-if is not in this version of angular. its introduce in angular 1.1.5

check it in angular under Directives topic change log

AngularJS first added the ngIf directive in 1.1.5

please update the angular version and that will solve your problem. :)

Upvotes: 4

Related Questions