• Stars
    star
    269
  • Rank 147,195 (Top 3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 8 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Reactive Router for Angular

@ngrx/router

This project is DEPRECATED

The Angular 2 Router was inspired by the ngrx/router, shares a familiar API and will be updated going forward. The ngrx/router may continue to live on as a framework agnostic router with more experimental features.

Migration Guide to Angular Router

Reactive Router for Angular 2

npm version

This is an alternative router for Angular 2 focused on providing a simple, reactive API built to scale for large applications.

Please note that we are currently in beta. We believe the core of the router is solid and we do not expect anymore breaking changes to the API.

Installation

Install @ngrx/router and @ngrx/core into your Angular 2 project via npm:

npm install @ngrx/router @ngrx/core --save

Routing Setup

  1. Create your application components:
import { Component } from '@angular/core';

@Component({
  selector: 'app',
  template: `
    <h1>My Blog</h1>
    <nav>
      <a linkTo="/">Home</a>
      <a linkTo="/blog">Blog</a>
    </nav>

    <route-view></route-view>
  `
})
class App { }

@Component({
  selector: 'home-page',
  template: `
    <h2>Home Page</h2>
  `
})
class HomePage { }

@Component({
  selector: 'blog-page',
  template: `
    <h2>Blog</h2>
    <nav>
      <a *ngFor="let post of posts" [linkTo]="'/blog/' + post.id">{{ post.title }}</a>
    </nav>

    <route-view></route-view>
  `
})
class BlogPage { }

@Component({
  selector: 'post-page',
  template: `
    <h3>Post</h3>
  `
})
class PostPage { }
  1. Configure your application routes:
import { Routes } from '@ngrx/router';

const routes: Routes = [
  {
    path: '/',
    component: HomePage
  },
  {
    path: '/blog',
    component: BlogPage,
    children: [
      {
        path: ':id',
        component: PostPage
      }
    ]
  }
]
  1. Register router in application bootstrap.
import { provideRouter } from '@ngrx/router';

bootstrap(App, [
  provideRouter(routes)
]);

That's it! You are ready to begin taking advantage of reactive routing!

Documentation

More Repositories

1

platform

Reactive State for Angular
TypeScript
7,848
star
2

store

RxJS powered state management for Angular applications, inspired by Redux
TypeScript
3,911
star
3

example-app

Example app showcasing the ngrx platform
TypeScript
1,363
star
4

effects

Side effect model for @ngrx/store
TypeScript
533
star
5

store-devtools

Developer Tools for @ngrx/store
TypeScript
327
star
6

db

RxJS powered IndexedDB for Angular apps
TypeScript
186
star
7

router-store

Bindings to connect the Angular Router to @ngrx/store
TypeScript
183
star
8

ngrx.github.io

Reactive Extensions for Angular
HTML
114
star
9

notify

Web Notifications Powered by RxJS for Angular
TypeScript
101
star
10

core

Core functionality for the ngrx platform
TypeScript
74
star
11

store-log-monitor

Log Monitor for @ngrx/store-devtools and Angular
TypeScript
63
star
12

store-builds

@ngrx/store build artifacts
JavaScript
16
star
13

store-devtools-builds

@ngrx/store-devtools build artifacts
JavaScript
10
star
14

entity-builds

@ngrx/entity build artifacts
JavaScript
8
star
15

signal-store-workshop

Source Code for NgRx SignalStore Workshop
TypeScript
8
star
16

component-store-builds

@ngrx/component-store build artifacts
JavaScript
6
star
17

angular

TypeScript
5
star
18

schematics-builds

@ngrx/schematics build artifacts
4
star
19

ngrx-io-builds

ngrx.io builds
HTML
4
star
20

signals-builds

JavaScript
3
star
21

router-store-builds

@ngrx/router-store build artifacts
JavaScript
2
star
22

ngrx-io-previews

ngrx.io preview builds
HTML
1
star
23

data-builds

@ngrx/data build artifacts
JavaScript
1
star
24

effects-builds

@ngrx/effects build artifacts
JavaScript
1
star