Join Alexander Zanfir for an in-depth discussion in this video Show logout in our navbar, part of MEAN Stack and MongoDB: Development Techniques.
- [Voiceover] In this video, we will…show a log out button, instead of…the login button, if we are already logged in.…We can determine if we are logged in…by looking at the localStorage for a token.…But Satellizer makes it easier for us by…providing an isAuthenticated function.…The first thing we need to do is…create a controller for our navView.…Since it didn't have any functionality…until now, it did not need a controller,…but we will now have to check if we…are authenticated to modify what…button we are showing in the navbar.…
So, let's navigate to components, and then navbar.…And now let's create a new file.…We'll call it navbar.controller.js.…And now let's export a class called NavbarController.…And next, let's create a constructor.…And we'll inject the auth service…so that we have access to Satellizer.…And as usual, we'll use ngInject,…since we are injecting a service.…
Now, let's open up our navbar.html.…Inside here, we can add an ngController directive,…since we won't be setting up the controller…with our router, as we did for the other views.…
- Installing and setting up your MEAN toolset
- Making an Angular post form
- Sending posts
- Displaying messages
- Creating a registration form
- Saving users
- Associating users with posts
- Authenticating users at login
Skill Level Intermediate
2. Message Posting
3. Display Messages
Save a user with Mongo13m 26s
5. Logging In
Next steps2m 5s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.