Hacker News Clone in AngularJS – Post 4, Part D (2): Adds StoryComment Component with ngSanitize
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:
* adding a link to our Story Comment component in index.html via a script tag with a source of “js/app/components/StoryComment.js”
* using the Angular ngSanitize module by adding ‘ngSanitize’ to our array of dependencies in app.js
* adding some properties on our view model object within our StoryComment component: vm.commentText, vm.commentAuthor, vm.commentTime
* using ng-bind-html within the story-comment.html template to display the html ‘text’ property retrieved from the Hacker News API and stored in vm.commentText
* adding vm.commentAuthor and vm.commentTime to our story-comment.html template
* checking http://localhost:8080/#/post?id=1 to see the results of our changes.
When we’re done, we’ll have a component that properly displays a comment based on data retrieved from the Hacker News API.