" />
" />
"/>
DEVHIDE
  • Home (current)
  • About
  • Contact
  • Cookie
  • Home (current)
  • About
  • Contact
  • Cookie
  • Disclaimer
  • Privacy
  • TOS
Login Or Sign up

Angular 6 - RouterLink navigates but not changing URL

10.6k Views Asked by balachander j At 01 June 2018 at 18:50 2025-12-20T03:13:01.880000

app.component.html

<nav>
 <a routerLink="/dashboard"></a>
 <a routerLink="/reports"></a>
<nav>
<main role="main" class="page-container">
  <router-outlet></router-outlet>
</main>

app-routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DashboardComponent } from './dashboard/dashboard.component';
import { ReportsComponent } from './reports/reports.component';

const routes: Routes = [
  { path: 'dashboard', component: DashboardComponent },
  { path: 'reports', component: ReportsComponent },
  { path: '',
    redirectTo: '/dashboard',
    pathMatch: 'full'
  }];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { DashboardComponent } from './dashboard/dashboard.component';
import { ReportsComponent } from './reports/reports.component';


@NgModule({
  declarations: [
    AppComponent,
    DashboardComponent,
    ReportsComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {

}

With the above code, I see that on click of the nav links, am able to navigate to the corresponding component but for some reason, URL is not getting updated.

Not sure if am missing something pretty basic here. Please help.

angular angular-cli angular-router routelink
Original Q&A
1

There are 1 best solutions below

2
Serhii Andronik Serhii Andronik On 07 June 2018 at 15:37 BEST ANSWER

if you are running hybrid app(with upgrade module) add useHash to router config

imports: [RouterModule.forRoot(routes, { useHash: true, enableTracing: true })],

Related Questions in ANGULAR

  • Firebase link existing user to anonymous account?
  • It doesnt always show all the books on my homepage
  • Google adsense ads.txt status cannot be not found
  • When I navigate to the URL'http://localhost:4200/', it redirects me back
  • Ionic Angular Standalone ion-icon are not showing at all
  • How to make Angular understand that view child is of a specific type, not a general ElementRef?
  • vscode, debug angular, first time, doesn't debug, 2nd time stops at main.js then it's ok
  • How to perform CRUD operations on a static JSON array in Angular? (without API)
  • Ngrx props<>() method in createAction()
  • How to animate rotation of an image inside input control?
  • Detecting click inside and outside of the listening component in Angular
  • Angular - type guard not narrowing types
  • In node_modules file i am getting Angular genric error while using fontawesome in angular12
  • Angular 16 sending null values to API
  • GoogleCloud Error: Not Found The requested URL was not found on this server

Related Questions in ANGULAR-CLI

  • FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory in angular application
  • What is the use of "Hash: fec054139de85795" in ng serve?
  • Angular esbuild @angular/compiler missing from bundle file
  • Angular build for subfolder
  • angular.json : configuration for multiple library projects
  • Getting Cannot read property 'polyfillWrapFlushCallback' of undefined
  • Unable to install angular-cli on Windows 7 (using npm)
  • This version of CLI is only compatible with Angular versions ^15.0.0, but Angular version 17.2.4 was found instead
  • angular cli installation cannot be completed
  • how can i use yarn with PnP in an already angular project?
  • Angular CLI and node-gyp : Cannot assign to read only property 'cflags' of object '#<Object>'
  • Angular v10: how do i handle this overlay issue of p-calendar
  • Node.js version v16.20.2 detected. The Angular CLI requires a minimum of v18.13
  • Angular: How to extract i18n ids from json source files to outpur it in xlf files
  • configure Angular app with powers of deployUrl without using due to depreciation warning. (not baseHref)

Related Questions in ANGULAR-ROUTER

  • Compilation error in RouterEvent after migration from angular 15 to 16
  • Dynamically updating Angular routes based on observable changes
  • How to scroll to top on route change in Angular with provideRouter?
  • Angular route management with oidc client
  • Angular 15: Why are my input elements empty when wrapped with a router-outlet?
  • How to make several routes on one component and not to redraw them unnecessarily, Angular
  • Angular14 Save nested component state to reuse it in another route
  • If resolvers run after guards, how are you supposed to get user data?
  • How to route to a "subcomponent" in Angular
  • How can I write a Jest unit test for an Angular 17 CanActivateFn guard that rely on createUrlTreeFromSnapshot?
  • Angular Routing: Popstate back does not trigger previous route
  • Creating custom Router class in Angular leads to exception
  • Angular back button from external app with skipLocationChange
  • Can the Angular router be configured to update Angular routes when anchors with local href's are clicked?
  • How make my component take all available space with Tailwind?

Related Questions in ROUTELINK

  • How to make my gatsby link work properly in netlify?
  • Can't reach user component using -> [routerLink]=" '/profile/ ' + currentUser.id"
  • Angular 8 - URL loads with routerLink but doesn't show when directly access in the browser in LOCALHOST
  • Angular 6 - RouterLink navigates but not changing URL
  • Clicking on routelink url not passing all the data to action
  • How can I add a click event to innerHtml in Angular 4
  • Angular2 RouteLink doesn't work in "a" tag but it's work when I tip it in navigation bar of browser
  • Angular: Multiple nested routes
  • routeLink not rendered coorrectly while testing
  • .net HTML.RouteLink passes parameter as key-value pair not rout
  • Installing the correct DLLs to resolve ActionLink(...) and RouteLink(...) in a cshtml view
  • RouteLink testing angular2
  • Angular2 routeLink not working when querystring value is a 1
  • Insert current URL into @Html.RouteLink parameter to build a link
  • ASP MVC ActionLinks with HTML content

Trending Questions

  • UIImageView Frame Doesn't Reflect Constraints
  • Is it possible to use adb commands to click on a view by finding its ID?
  • How to create a new web character symbol recognizable by html/javascript?
  • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
  • Heap Gives Page Fault
  • Connect ffmpeg to Visual Studio 2008
  • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
  • How to avoid default initialization of objects in std::vector?
  • second argument of the command line arguments in a format other than char** argv or char* argv[]
  • How to improve efficiency of algorithm which generates next lexicographic permutation?
  • Navigating to the another actvity app getting crash in android
  • How to read the particular message format in android and store in sqlite database?
  • Resetting inventory status after order is cancelled
  • Efficiently compute powers of X in SSE/AVX
  • Insert into an external database using ajax and php : POST 500 (Internal Server Error)

Popular # Hahtags

javascript python java c# php android html jquery c++ css ios sql mysql r reactjs node.js arrays c asp.net json

Popular Questions

  • How do I undo the most recent local commits in Git?
  • How can I remove a specific item from an array in JavaScript?
  • How do I delete a Git branch locally and remotely?
  • Find all files containing a specific text (string) on Linux?
  • How do I revert a Git repository to a previous commit?
  • How do I create an HTML button that acts like a link?
  • How do I check out a remote Git branch?
  • How do I force "git pull" to overwrite local files?
  • How do I list all files of a directory?
  • How to check whether a string contains a substring in JavaScript?
  • How do I redirect to another webpage?
  • How can I iterate over rows in a Pandas DataFrame?
  • How do I convert a String to an int in Java?
  • Does Python have a string 'contains' substring method?
  • How do I check if a string contains a specific word?

Copyright © 2021 Jogjafile Inc.

  • Disclaimer
  • Privacy
  • TOS
  • Homegardensmart
  • Pricesm.com
  • Aftereffectstemplates
  • Jogjafile