Skip to content
This repository was archived by the owner on Apr 12, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/app/navbar/navbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<ul class="navbar-nav ml-auto">
<li><a class="nav-link" href="#">Home</a></li>
<li><a class="nav-link" href="#">Sign Up</a></li>
<li><a *ngIf="isLoggedin()" class="nav-link">{{username}}</a></li>
<li><a class="nav-link" href="#"> <i class="fa fa-user"></i>&nbsp;&nbsp;<i class="fa fa-ellipsis-v"></i></a></li>
</ul>
</div>
Expand Down
14 changes: 14 additions & 0 deletions src/app/navbar/navbar.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { User } from '../services/user.service';

@Component({
selector: 'app-navbar',
Expand All @@ -9,6 +10,19 @@ export class NavbarComponent implements OnInit {

constructor() { }

username:string;

isLoggedin(){

const name_exists = localStorage.getItem('username');
if(name_exists){
this.username = name_exists;
return true;
}
else{
return false;
}
}
ngOnInit() {
}

Expand Down
3 changes: 3 additions & 0 deletions src/app/services/authentication.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import { Injectable } from '@angular/core';
body.set('username', user.username);
body.set('password', user.password);

// Store Username in Local Storage
localStorage.setItem('username',user.username);

const options = {
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')
.set('Access-Control-Allow-Origin', '*')
Expand Down