javascript - Filtering a List via a Sidebar -
there 2 lists of items. 1 blog posts, , 1 authors.
var app = angular.module("blog", []); app.controller('postctrl', function($scope) { $scope.posts = <%= @posts.to_json.html_safe %>; $scope.authors = <%= @authors.to_json.html_safe %>; });
the information provided through database via rails. if don't know rails, assume have been given big chunk of json work with.
now, list blog posts:
<div id="blog-posts" ng-controller="postctrl"> <article class="post" ng-repeat="post in posts"> <h1> {{ post.title }} </h1> <small> {{ post.author }} on {{ post.created_at }} </small> <p> {{ post.body }} </p> </article> </div>
and decide make aside within #blog-posts
div (so within postsctrl) list authors:
<aside> <h2> authors </h2> <ul> <li ng-repeat="author in authors"> {{ author.name }} </li> </ul> </aside>
its nice you're listing , displaying authors, want allow people filter based on author.
key question: how 1 filter blog posts when clicking on author?
Comments
Post a Comment