File tree Expand file tree Collapse file tree
apps/angular/22-router-input/src/app Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { ApplicationConfig } from '@angular/core' ;
2- import { provideRouter } from '@angular/router' ;
2+ import { provideRouter , withComponentInputBinding } from '@angular/router' ;
33import { appRoutes } from './app.routes' ;
44
55export const appConfig : ApplicationConfig = {
6- providers : [ provideRouter ( appRoutes ) ] ,
6+ providers : [ provideRouter ( appRoutes , withComponentInputBinding ( ) ) ] ,
77} ;
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 } 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+ testId = input < string > ( ) ;
14+ user = input < string > ( ) ;
15+ permission = input < string > ( ) ;
2116}
You can’t perform that action at this time.
0 commit comments