Socket
Socket
Sign inDemoInstall

@angular/router

Package Overview
Dependencies
7
Maintainers
2
Versions
810
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @angular/router

Angular - the routing library


Version published
Maintainers
2
Created

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

18.0.0-next.5 (2024-04-17)

Breaking Changes

common

  • The deprecated isPlatformWorkerUi and isPlatformWorkerApp have been removed without replacement, as they serve no purpose since the removal of the WebWorker platform.

compiler

  • Angular only supports writable expressions inside of two-way bindings.

core

  • Angular will ensure change detection runs, even when the state update originates from outside the zone, tests may observe additional rounds of change detection compared to the previous behavior.

    This change will be more likely to impact existing unit tests. This should usually be seen as more correct and the test should be updated, but in cases where it is too much effort to debug, the test can revert to the old behavior by adding provideZoneChangeDetection({schedulingMode: NgZoneSchedulingMode.NgZoneOnly}) to the TestBed providers.

    Similarly, applications which may want to update state outside the zone and not trigger change detection can add provideZoneChangeDetection({schedulingMode: NgZoneSchedulingMode.NgZoneOnly}) to the providers in bootstrapApplication or add schedulingMode: NgZoneSchedulingMode.NgZoneOnly to the BootstrapOptions of bootstrapModule.

  • Testability methods increasePendingRequestCount, decreasePendingRequestCount and getPendingRequestCount have been removed. This information is tracked with zones.

common

| Commit | Type | Description | | -- | -- | -- | | 3b0de30b37 | refactor | remove deprecated isPlatformWorkerApp and isPlatformWorkerUi API (#55302) |

compiler

| Commit | Type | Description | | -- | -- | -- | | 7d5bc1c628 | fix | remove container index from conditional instruction (#55190) | | 4eb0165750 | fix | remove support for unassignable expressions in two-way bindings (#55342) |

core

| Commit | Type | Description | | -- | -- | -- | | fdd560ea14 | feat | Add ability to configure zone change detection to use zoneless scheduler (#55252) | | bce5e2344f | feat | Add build target for jsaction contract binary. (#55319) | | f09c5a7bc4 | feat | Add zoneless change detection provider as experimental (#55329) | | d28614b90e | feat | Modify EventType from an enum to an object. (#55323) | | 1ee9f32621 | feat | Synchronize changes from internal JSAction codebase. (#55182) | | de7447d15e | fix | Angular should not ignore changes that happen outside the zone (#55102) | | 0cec9e4f9a | fix | Fix null dereference error addEvent (#55353) | | 6534c035c0 | fix | Remove deprecated Testability methods (#53768) |

service-worker

| Commit | Type | Description | | -- | -- | -- | | 3bc63eaaf3 | fix | avoid running CDs on controllerchange (#54222) |

<!-- CHANGELOG SPLIT MARKER -->

<a name="17.3.5"></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 17 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