Socket
Socket
Sign inDemoInstall

@angular/router

Package Overview
Dependencies
7
Maintainers
2
Versions
804
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @angular/router

Angular - the routing library


Version published
Weekly downloads
2.2M
decreased by-20.31%
Maintainers
2
Install size
2.30 MB
Created
Weekly downloads
 

Package description

What is @angular/router?

The @angular/router package provides navigation and URL manipulation capabilities for Angular applications. It allows developers to define routes, navigate between them, handle route parameters, and guard routes among other functionalities.

What are @angular/router's main functionalities?

Route Configuration

Defines routes in an Angular application, associating paths with components.

const routes: Routes = [
  { path: 'home', component: HomeComponent },
  { path: 'about', component: AboutComponent }
];

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

Router Outlet

A placeholder that Angular dynamically fills based on the current router state.

<router-outlet></router-outlet>

Navigation

Programmatically navigate to different routes within an Angular application.

constructor(private router: Router) { }

navigateToHome() {
  this.router.navigate(['/home']);
}

Route Parameters

Access parameters for a given route, often used for fetching data based on the URL.

constructor(private route: ActivatedRoute) { }

ngOnInit() {
  this.route.paramMap.subscribe(params => {
    this.userId = params.get('id');
  });
}

Route Guards

Protect routes with guards that can allow or prevent navigation to a route based on logic such as authentication.

@Injectable({ providedIn: 'root' })
export class AuthGuard implements CanActivate {
  canActivate(
    next: ActivatedRouteSnapshot,
    state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
    return this.authService.isAuthenticated();
  }
}

Other packages similar to @angular/router

Changelog

Source

17.3.4 (2024-04-10)

common

| Commit | Type | Description | | -- | -- | -- | | 53427d875d | fix | invalid ImageKit quality parameter (#55193) | | 766548c3ec | fix | skip transfer cache on client (#55012) |

<!-- CHANGELOG SPLIT MARKER -->

<a name="18.0.0-next.3"></a>

Readme

Source

Angular

The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.

Usage information and reference details can be found in Angular documentation.

License: MIT

Keywords

FAQs

Last updated on 10 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc