Book Image

AngularJS Web Application Development Blueprints

By : Vinci J Rufus
Book Image

AngularJS Web Application Development Blueprints

By: Vinci J Rufus

Overview of this book

Table of Contents (17 chapters)
AngularJS Web Application Development Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 template:"Welcome {{username}}" to templateUrl: 'partials/greeting.html'.

We now need to create a new HTML file in the partials folder named greeting.html, and add in the following code:

<span class="pull-right">
    <span id="welcome" ng-if...