you cannot navigate to another route without changing the URL... you can
only screw with the history by reading about navigationextras from the
doc...
skipLocationChange boolean
Navigates without pushing a new state into history.
// Navigate silently to /view
this.router.navigate(['/view'], { skipLocationChange: true });
replaceUrl boolean
Navigates while replacing the current state in history.
// Navigate to /view
this.router.navigate(['/view'], { replaceUrl: true });
On Sat, Dec 21, 2019 at 2:37 AM ahmed elbarbary <[email protected]>
wrote:
> I work on web app done by angular 7
> I need when click on any item on list on have router link on
> nvabar.component.html go to specified component on router link
> without change URL .
> navbar.component.html
> <div id="z2-2cols-leftpanel">
> <ul class="z2-leftpanel-ullinks">
> <li>
> <a routerLink="/overview" class="active z2tabBtn" data-z2tab=
> "overview_content">
> <div class="z2iconfont icon-Basic-Info"></div>
> <div class="ulllinks-text">Overview</div>
> </a>
> </li>
> <li>
> <a routerLink="/family" class="z2tabBtn" data-z2tab=
> "family_content">
> <div class="z2iconfont icon-Cross-Reference"></div>
> <div class="ulllinks-text">Family</div>
> </a>
> </li>
> <li>
> </ul>
> </div>
>
>
>
> in app-routing.module.ts
> { path: 'overview', component: OverviewComponent },
> { path: 'family', component: FamilyComponent }
>
> on overview.component.ts
>
>
> import { CompanyService } from './../../service/company.service';
> import { Component, OnInit } from '@angular/core';
> import { PartDetailsService } from 'src/app/service/part-details.service';
>
>
>
>
>
> @Component({
> selector: 'app-overview',
> templateUrl: './overview.component.html',
> styleUrls: ['./overview.component.css']
> })
> export class OverviewComponent implements OnInit {
>
>
>
> public companyProfile;
> constructor(public partDetailsService: PartDetailsService
> , public companyService: CompanyService) {
>
> }
>
>
> ngOnInit() {
> console.log("welcome overview component ");
> }
>
> so I need when click on link overview on navbar.component.html
> go to component overview and show welcome on console without change URL
> so
> How to do that please ?
> current status is when click on link overview exist on navbar it go to
> overview component
> but it change URL
> what i need is when click overview link go to component overview but not
> change URL ?
> Example
> suppose i have URL localhost:4200/family
> when click overview component go to overview component but not change URL
> to localhost:4200/overview meaning
> link localhost:4200/family will be in URL although i click overview
> component and show message on console welcome overview
>
> --
> You received this message because you are subscribed to the Google Groups
> "Angular and AngularJS discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/angular/15659218-a57f-4186-960a-fd90f1eaaa70%40googlegroups.com
> <https://groups.google.com/d/msgid/angular/15659218-a57f-4186-960a-fd90f1eaaa70%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/angular/CANmMz6TrmyaR%3D_Z6UN7ST5SK2NrfnWMy2aUhw099MACA7ShozQ%40mail.gmail.com.