I'm new to angularjs, and now what I need to do with angularjs is a grid view which is pretty much like viewing files with large icon in Windows explorer.
I've sort of finished the view, and what I need to do now is to implement a "favorite" feature. There's a button to set a file to be my favorite file, and there's also a button to let the grid view only show my favorite files.
Is there any existing design pattern doing this by angularjs? Or it's just as simple as setting the "display" to "none" to those files that are not my favorite files?
What would be the best practice to make my code of this feature to be unit-testable?
Maybe just using the angular ng-hide or ng-show directive to show only the favorites or hide the ones that aren't.
Your objects should have a property like IsFavorite
. This way you can use filters to filter the displayed items:
<select ng-model="myFilter">
<option value="All">All</option>
<option value="IsFavorite">Favorites</option>
</select>
<ul>
<li ng-repeat="item in items | filter: myFilter">{{ item.title }}</li>
</ul>