So I am building a simple MVC application that displays a grid of icons.
The View gets passed a List of models, then uses a @foreach
loop to display them in the following manner
<div class="rows">
@foreach (var item in Model)
{
<div class="column">
@Html.DisplayFor(modelItem => item.size)
</div>
}
</div>
I want to be able to hide/show certain items based on their content, and I want to be able to toggle that with a button.
So for example, I might want to have a button that when pressed, will hide all columns displaying an item where item.info == SomeValue
I've messed around with ng-hide
and ng-if
but I can't figure out a way to only hide certain items.
Here is the angular component I've come up with:
var app = angular.module(toggleDisplay, []);
app.controller("displayMode", function($scope) {
$scope.displayLarge;
});
But as I said I can only figure out how to hide the whole list. I want to use Angular to be able to toggle it so that, for example, it only displays the item when item.size == large
. So if the box is unchecked it displays the whole list, but if I check it, it only displays large items.
I've never worked with angular before and I can't figure out a pattern to make this work. It's possible I'm coming at it all wrong.
Here's the app that hides the whole list:
<script>
var app = angular.module(toggleDisplay, []);
app.controller("displayMode", function($scope) {
$scope.displayAll;
});
</script>
<div ng-app="toggleDisplay" ng-controller="displayMode">
<input type="checkbox" ng-model="displayAll"/>
<div class="rows">
<div class="ng-hide" ng-hide="displayAll">
@foreach (var item in Model)
{
<div class="column">
@Html.DisplayFor(modelItem => item.size)
</div>
}
</div>
</div>
</div>