From "Build Your Own Angular JS" book by Tero Parviainen