Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@angular/router
Advanced tools
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.
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();
}
}
React Router is a routing library for React, similar to @angular/router but for React applications. It provides components for navigation, route matching, and history handling. While @angular/router is designed specifically for Angular, React Router is tailored to React's component structure.
Vue Router is the official router for Vue.js. It integrates deeply with Vue.js core to make building Single Page Applications with Vue.js a breeze. It offers features similar to @angular/router but is designed to work seamlessly with Vue.js components and reactivity system.
Reach Router is a small, simple router for React that is accessible and easy to use. It is similar to @angular/router in providing navigation and route matching, but it focuses on simplicity and accessibility. It has now been succeeded by React Router, which has incorporated its accessibility features.
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
19.1.0 (2025-01-15)
| Commit | Type | Description | | -- | -- | -- | | e4c50b3bea | feat | expose component instance in NgComponentOutlet (#58698) |
| Commit | Type | Description | | -- | -- | -- | | ceadd28ea1 | fix | allow $any in two-way bindings (#59362) | | aed49ddaaa | fix | use chunk origin in template HMR request URL (#59459) |
| Commit | Type | Description | | -- | -- | -- | | c5c20e9d86 | fix | check event side of two-way bindings (#59002) |
| Commit | Type | Description | | -- | -- | -- | | d010e11b73 | feat | add event listener options to renderer (#59092) | | 57f3550219 | feat | add utility for resolving defer block information to ng global (#59184) | | 22f191f763 | feat | extend the set of profiler events (#59183) | | e894a5daea | feat | set kind field on template and effect nodes (#58865) | | bd1f1294ae | feat | support TypeScript 5.7 (#58609) | | 9870b643bf | fix | Defer afterRender until after first CD (#58250) | | a5fc962094 | fix | Don't run effects in check no changes pass (#58250) |
| Commit | Type | Description | | -- | -- | -- | | d298d25426 | feat | add schematic to clean up unused imports (#59353) | | 14fb8ce4c0 | fix | resolve text replacement issue (#59452) |
| Commit | Type | Description | | -- | -- | -- | | 8c5db3cfb7 | fix | avoid circular DI error in async renderer (#59256) |
| Commit | Type | Description |
| -- | -- | -- |
| 52a6710f54 | fix | complete router events
on dispose (#59327) |
<a name="19.0.7"></a>
FAQs
Angular - the routing library
The npm package @angular/router receives a total of 1,944,497 weekly downloads. As such, @angular/router popularity was classified as popular.
We found that @angular/router demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
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.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.