O'Reilly logo

AngularJS: Novice to Ninja by Sandeep Panda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11Adding a Comment System to Single Page Blogger

Every blogging app has an integrated comment system and obviously our Single Page Blogger would be incomplete without one. We're going to build a simple comment system by creating a custom directive. Let's name this directive spb-comments. Here is its initial structure:

angular.module('spBlogger.posts.directives',[]).
↵directive('spbComments',function(Post){
   return {
       restrict:'AEC',
       scope:{
           postInstance:'='
       },
       replace:true,
       link:function(scope,elem,attrs){

       },
       templateUrl:'modules/posts/views/comments.html'
   }
});

The code goes into the file: modules/posts/js/directives.js.

As you can see, the directive creates an isolated scope. The isolated scope has a property called postInstance. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required