last day (15 days later) » 

07:04
0
Q: Unable to hide the navigation bar in login page when redirecting from home page to login page

HeenaI am trying to implement a sample app in Angular using Angular Material and Angular Flex Layout. I have implemented a navigation bar which is hidden in login page and visible in all pages in the appllication. I have created a service with the name showmenu.service.ts where I have declared two v...

Please provide working code
Can you please check this out......... stackblitz.com/edit/…
@VivekDoshi. .......... can you please check this link ...... stackblitz.com/edit/…
still i can see Can't find package:hammerjs
@RameshRajendran.... stackblitz.com/edit/…... please check this...!
Which line are you getting this error?
07:05
in app.component.html.......... as shown in the output console in the question......!
try this
if(this.user.username=="a" && this.user.password=="a"){
alert("valid..!!");
else{
alert("Please Enter Valid Username/Password..!!");
}
without using this.route.... code
and let mw know the result
No don't try that
Still example is not workin @Heena , I think @RameshRajendran can solve the issue , Let me know if you still don't figure it out.
kindly let me know have you used any service call in you componenet?
yes i have created a service with the name showmenu.service.ts.
where I called this service in myform component to hide the navigation bar..
try this instead of your home componenet
07:15
???
import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
import {ShowmenuService} from '../showmenu.service';

import { ActivatedRoute, Params } from '@angular/router';


@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})


export class HomeComponent implements OnInit {

constructor(public showmenu:ShowmenuService, private _activateroute: ActivatedRoute ) { }
private cd: ChangeDetectorRef;
ngOnInit() {
this.showmenu.show1();
copy past that code instead of your compoenent and let me know
I am getting this error in my console now .....ERROR TypeError: "this.cd is undefined"
oops add this in your constructor private cd: ChangeDetectorRef;
instead of declaring
private cd: ChangeDetectorRef; is already added...!
try import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
import {ShowmenuService} from '../showmenu.service';

import { ActivatedRoute, Params } from '@angular/router';


@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})


export class HomeComponent implements OnInit {

constructor(public showmenu:ShowmenuService, private _activateroute: ActivatedRoute,private cd: ChangeDetectorRef ) { }

ngOnInit() {
this.showmenu.show1();
try the latest code
07:22
again I am getting the previous error.........ERROR Error: "ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'false'. Current value: 'true'."
try this
<div>
<mat-toolbar color="primary" fxLayoutAlign="space-between end" style="height: 5vh;">

<h2> <span class="span">MY &emsp; ANGULAR &emsp; APP</span></h2>

<button mat-icon-button [matMenuTriggerFor]="project" [hidden]="!showmenu.visible1" >
<mat-icon style="-webkit-text-fill-color: white; padding-top:10px;"> account_circle </mat-icon>

<mat-menu #project="matMenu" [overlapTrigger]="false">
<button mat-menu-item class="m" routerLink='/myform' ><span class="m1">Log Out</span></button>
</mat-menu>
instead of your app componenet.html
But with this I am getting the navigation bar in my login page also............
may be you need to check the condition for !showmenu.visible1 . remove ! and try
yes i tried even that .... but the navigation bar is visible in login page...
This error is gone?
07:36
there is no error in console now with this latest code ... but i dont want nav bar to appear in my login page...
Then your logic was not correct.
are you talking about the showmenu service..?
Yes exactly
even i was struggling with that but was unable to resolve...
please help me implementing this service ....!
Ok
Could you please check this?
Check
and check all the screens as well and let me know
07:59
still I am getting nav bar in login page.....
also I am getting this error in my console......
Oh ...
you are getting another error like cd is undefined
Just remove ChangeDetectorRef related code and then try
08:12
If it works then don't forgot to mark as the answer :)
08:47
the error is removed now but still the nav bar is visible in my login page...
Are you getting any error?
no
ChangeDetectorRef issue is gone?
yes ..
Ok could you update latest codes in stackblitz
08:56
ok .. 5 minutes please
stackblitz.com/edit/…;. can you please have a look.................?
09:10
I am not sure dude. I will go to lunch . so better to ask a new question....
ok ... thanks for help .. i will raise a new question....
09:58
@VivekDoshi............ can you please help me with this.......stackoverflow.com/questions/50387896/…

last day (15 days later) »