File tree Expand file tree Collapse file tree
apps/angular/22-router-input/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { AsyncPipe } from '@angular/common' ;
2- import { Component , inject } from '@angular/core' ;
3- import { ActivatedRoute } from '@angular/router' ;
4- import { map } from 'rxjs' ;
1+ import { Component , Input as RouterInput } from '@angular/core' ;
52
63@Component ( {
74 selector : 'app-subscription' ,
8- imports : [ AsyncPipe ] ,
5+ imports : [ ] ,
96 template : `
10- <div>TestId: {{ testId$ | async }}</div>
11- <div>Permission: {{ permission$ | async }}</div>
12- <div>User: {{ user$ | async }}</div>
7+ <div>TestId: {{ testId }}</div>
8+ <div>Permission: {{ permission }}</div>
9+ <div>User: {{ user }}</div>
1310 ` ,
1411} )
1512export default class TestComponent {
16- private activatedRoute = inject ( ActivatedRoute ) ;
17-
18- testId$ = this . activatedRoute . params . pipe ( map ( ( p ) => p [ 'testId' ] ) ) ;
19- permission$ = this . activatedRoute . data . pipe ( map ( ( d ) => d [ 'permission' ] ) ) ;
20- user$ = this . activatedRoute . queryParams . pipe ( map ( ( q ) => q [ 'user' ] ) ) ;
13+ @RouterInput ( ) testId ! : string ;
14+ @RouterInput ( ) permission ! : string ;
15+ @RouterInput ( ) user ! : string ;
2116}
Original file line number Diff line number Diff line change 1- import { provideZoneChangeDetection } from '@angular/core' ;
21import { bootstrapApplication } from '@angular/platform-browser' ;
2+ import { provideRouter , withComponentInputBinding } from '@angular/router' ;
33import { AppComponent } from './app/app.component' ;
4- import { appConfig } from './app/app.config ' ;
4+ import { appRoutes } from './app/app.routes ' ;
55
66bootstrapApplication ( AppComponent , {
7- ...appConfig ,
8- providers : [ provideZoneChangeDetection ( ) , ...appConfig . providers ] ,
9- } ) . catch ( ( err ) => console . error ( err ) ) ;
7+ providers : [ provideRouter ( appRoutes , withComponentInputBinding ( ) ) ] ,
8+ } ) ;
You can’t perform that action at this time.
0 commit comments