File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
apps/angular/32-change-detection-bug/src/app Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change 1- import { AsyncPipe } from '@angular/common' ;
21import { Component , inject , input } from '@angular/core' ;
2+ import { toSignal } from '@angular/core/rxjs-interop' ;
33import { RouterLink , RouterLinkActive } from '@angular/router' ;
44import { FakeServiceService } from './fake.service' ;
55
@@ -37,22 +37,22 @@ export class NavigationComponent {
3737}
3838
3939@Component ( {
40- imports : [ NavigationComponent , AsyncPipe ] ,
40+ imports : [ NavigationComponent ] ,
4141 template : `
42- @if (info$ | async; as info) {
43- @if (info !== null) {
44- <app-nav [menus]="getMenu(info)" />
45- } @else {
46- <app-nav [menus]="getMenu('')" />
47- }
42+ @if (info() !== null) {
43+ <app-nav [menus]="getMenu(info()!)" />
44+ } @else {
45+ <app-nav [menus]="getMenu('')" />
4846 }
4947 ` ,
5048 host : { } ,
5149} )
5250export class MainNavigationComponent {
5351 private fakeBackend = inject ( FakeServiceService ) ;
5452
55- readonly info$ = this . fakeBackend . getInfoFromBackend ( ) ;
53+ readonly info = toSignal ( this . fakeBackend . getInfoFromBackend ( ) , {
54+ initialValue : null ,
55+ } ) ;
5656
5757 getMenu ( prop : string ) {
5858 return [
You can’t perform that action at this time.
0 commit comments