In my angular2 project, the index.html
file contains a header bar. The responsibility of logging in and displaying other content is handled by different components.
I need to display a logo in the header bar only when a user is logged in. To achieve this, I am setting a flag in app.component.ts
to track the login status. How can I reference this flag in the index.html
file?
<body>
<div class="content-body">
<header class="header">
<div class="header-bar container">
<div class="header-bar__main">
<div class="header-heading">
<h1 class="page-title">noHold Application</h1>
</div>
</div>
<a class="btn btn--small btn--icon ng-scope" title="Logout"><span class="icon-sign-out"></span></a> // this line should be displayed only if user logs in.
</div>
</header>
<div class="content">
<div class="content__main">
<div class="container">
<app-root>Loading... </app-root>
</div>
</div>
</div>
</div>
</body>
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
static loggedIn = false;
getLoggedIn() {
return AppComponent.loggedIn;
}
}