Building a Hacker News Clone in AngularJS Part 4 – Angular Filters

Hi Everyone! I’m Dakota Lee Martinez. In this video series I’ll be using the Hacker News API to build out a Hacker News Clone in AngularJS.

These videos are accompanied by a series of blog posts at becomingaprogrammer.com. You can find the written explanation of the process and code samples there.

Building a Hacker News Clone in AngularJS Part 4 – Angular Filters

This video covers the following topics:

* using our ng1filter snippet to create our getDomainFromUrl filter.
* making sure that the filter’s input is a url using a regular expression from a blog post by Michael O’Riordan:
http://blog.mattheworiordan.com/post/13174566389/url-regular-expression-for-links-with-or-without
* moving our code from the StoryDirectiveController into our filter.
* injecting our filter as a dependency within the Story directive in js/app/directives/Story.js
* using our getDomainFromUrl filter within the Story directive controller.
* checking http://localhost:8080/#/top to make sure that the domains are all still appearing within parentheses.
* removing the original getHoursAgo function from the StoryDirectiveController.

source