Adding in the logout link

Now that the app is fully functional, let's add some finishing touches and clean up some code.

What we want to do now is, when the user is logged in, along with the welcome message, we want to show a logout link, which allows the user to log out from the application. We would also want to check the user session, and in case the user is not logged in, then show them the login button instead, just in case the login popup didn't automatically load up.

For all of this, we will need to make changes in the directive template, and since the content in the template is going to be long, we will replace the template option of the directive with the templateURL option.

Change the template option in app/directives.js, that is, from ...

Get AngularJS Web Application Development Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.