I have just working with Angular v6.0.3. I have a little experience with AngularJS v1.6.9
I'm designing a basic webpage with the landing page displaying 2 links: first one to login and the second one to sign up. On clicking the "login" link(I added a (click) event), I have given the routing to "/login"(login-form is a component) and also used ngIf to hide the original contents on the page. After moving to the login component, when I refresh the page "localhost:4200/login", the content I hid using ngIf is showing up again as the variable I used in ngIf is being reloaded to value 'true' on refresh.
How to resolve this? Thanks in advance :)
app.component.ts
export class AppComponent {
myVar = true;
divReplace = function(){
if(this.myVar == true)
{
this.myVar = false;
}
}
}
app.component.html
<div class="fullPage">
<header>Welcome</header>
</div>
<router-outlet></router-outlet>
<div class="fullPage">
<div *ngIf="myVar">
<h3>Please login or sign up to continue :))</h3><br>
<div id="x"><a routerLink="/login" (click)="divReplace()">Login</a> </div>
<div>New user? <a routerLink="/signup">Sign Up</a></div>
</div>
</div>
Login page after click on "login" link
I want the content showing under the login form to not show even after refresh. I even tried using constructor() and ngOnInit() so that the variable is initialzed only once but nothing seems to work. Even web searches yielded no solutions :(
Thanks in advance!