touinta
touinta

Reputation: 1031

Hide div if viewbag is true angular MVC

I have a ViewBag in my MVC Controller

ViewBag.total = true;

and I want to check it in my razor view with angular code and then to display or hide a div

<div ng-show="list" class="divList">

       content here

</div>

Update

 <div ng-show="'@(ViewBag.total)'">content</div>

I have try this too Angular ng If not working with razor syntax but it doesn't work for me. Any idea? Thank you

Upvotes: 0

Views: 1646

Answers (2)

touinta
touinta

Reputation: 1031

I finally dropped the idea of viewbag and solved the problem like that

<div ng-hide="myarray[0].myfield == 0 ">Content</div>

maybe is useful for someone else

Upvotes: 0

Rosan Shrestha
Rosan Shrestha

Reputation: 32

    @{
        var total= (string) ViewBag.total;
     }
    <div ng-if="total== 'true'">
    </div>

Updated : please Check this

@{
            var total= (string) ViewBag.total;
         }
        <div ng-if="total">
        </div>

use This

Upvotes: 0

Related Questions