Protected function that requires authentication

I have a public listing page, with a “like” button.

If clicking the “like” button without logged in, I want to pop-up a ng-modal login page for user to login (or registration) before running the rest of the “like” function.

Is there any example in codepen that I can refer to?

Thanks in advance!

Richard

Found this which is very useful: http://brewhouse.io/blog/2014/12/09/authentication-made-simple-in-single-page-angularjs-applications.html