Hacker News Clone in AngularJS – Post 4, Part F: Adding a Get Domain From Url Filter
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.
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:
* 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.