I have my data stored in an array of objects and it is being used to create a list on the page with ngRepeat
. The problem is that some of the values within the object are null and I want to hide just their line but not the whole object. I tried using ngHide
on the individual <li>
's but it doesn't collapse the row since its just hiding it and I don't really wanna reduce its height to zero through a function or additional css if I can just use the filter to do it automagically.
Despite my best efforts I cannot seem to write a custom filter that will hide the null rows and show the others. I once had it to the point of returning false
for the value if null but then I deleted it to try something else and forgot how I had gotten there (ugh no local versioning).
Here is a fiddle from a previous question of mine but it has all the pieces I am trying to filter. http://jsfiddle.net/E2GB9/9/
Format of the data:
function TypeCtrl($scope) {
$scope.styles = [
{name: 'Example 1', h1:'32px', h2:'24px', p:'12px', className:'example1'},
{name: 'Example 2', h1:'', h2:'24px', p:'12px', className:'example2'},
{name: 'Example 3', h1:'24px', h2:'', p:'12px', className:'example3'},
{name: 'Example 4', h1:'32px', h2:'24px', p:'', className:'example4'}];
}
ngRepeat
in the html:
<li ng-repeat="style in styles">
<span>Name: {{style.name}}</span><br>
<span>H1: {{style.h1}}</span><br>
<span>H2: {{style.h2}}</span><br>
<span>P: {{style.p}}</span><br>
<button class="btn-small" type="submit" ng-click="$parent.appliedStyle=style.className">Apply {{style.name}}</button>
</li>
So, if style.h1 == null
then I want to hide that row only; same for h2, p and so on.