AngularJS directive with DOM manipulation

I recently wanted to create a spoiler box with AngularJS but I didn’t want to have to inject anything other than the CSS3 classes and the directive name to make it work.

After a little bit of research I learned that you can intercept the AngularJS HTML compile process and make DOM manipulations then insert logic like normal.

This solidifies my love for AngularJS.

Here is the code I used for your reference.

 

 Dave

About David Parlevliet

Dave is long time developer with a passion toward teaching. He divides his time between his wife, her cat and his projects. He recently started using twitter so make sure to follow him!