This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@if (user.isHuman) { | |
<human-profile [data]="user" /> | |
} @else if (user.isRobot) { | |
<!-- robot users are rare, so load their profiles lazily --> | |
@defer { | |
<robot-profile [data]="user" /> | |
} | |
} @else { | |
<p>The profile is unknown! | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const HERO_API_URL = new InjectionToken<string>('HERO_API_URL'); | |
@Injectable() | |
export class HeroService { | |
// old way, 'string' has to be declared and is not type checked | |
constructor(@Inject(HERO_API_URL) private apiUrl: string) {} | |
// new way, type is automatically correct | |
private apiUrl = inject(HERO_API_URL); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function configureStoreWithFeature(feature: ...): Provider[] { | |
return [ | |
{ | |
provide: Store, | |
useFactory: () => { | |
const rootStore = inject(RootStore); | |
for (const feature of inject(STORE_FEATURE, [])) { | |
rootStore.registerFeature(feature); | |
} | |
return rootStore; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const ROUTES: Route[] = [ | |
/* ...other routes */ | |
{ | |
path: 'lazy', | |
loadComponent: () => import('./lazy.component').then(mod => mod.LazyPageComponent), | |
}, | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In a separate `lazy.routing.ts` file: | |
@NgModule({ | |
imports: [ | |
LazyPageModule, | |
RouterModule.forChild([ | |
{path: '', pathMatch: 'full', component: LazyPageComponent}, | |
]), | |
], | |
}) | |
export class LazyPageRoutingModule {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as i0 from './test'; | |
import * as i1 from '@angular/common'; | |
import * as i2 from '@angular/core'; | |
const _ctor1: <T = any, U extends i2.NgIterable<T> = any>(init: Pick<i1.NgForOf<T, U>, "ngForOf" | "ngForTrackBy" | "ngForTemplate">) => i1.NgForOf<T, U> = null!; | |
/*tcb1*/ | |
function _tcb1(ctx: i0.TestCmp) { if (true) { | |
var _t1 /*T:DIR*/ /*165,197*/ = _ctor1({ "ngForOf": (((ctx).users /*190,195*/) /*190,195*/) /*187,195*/, "ngForTrackBy": null as any, "ngForTemplate": null as any }) /*D:ignore*/; | |
_t1.ngForOf /*187,189*/ = (((ctx).users /*190,195*/) /*190,195*/) /*187,195*/; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<span *ngFor="let user of users">{{user.name}}</span> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export declare class NgIf<T> { | |
// … | |
static dir: ng.DirectiveDeclaration<NgIf<any>, "[ngIf]", never, { "ngIf": "ngIf"; "ngIfThen": "ngIfThen"; "ngIfElse": "ngIfElse"; }, {}, never>; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export declare class CommonModule { | |
static mod: ng.NgModuleDeclaration<CommonModule, [typeof NgClass, typeof NgComponentOutlet, typeof NgForOf, typeof NgIf, typeof NgTemplateOutlet, typeof NgStyle, typeof NgSwitch, typeof NgSwitchCase, typeof NgSwitchDefault, typeof AsyncPipe, ...]>; | |
// … | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@NgModule({ | |
declarations: [ImageViewerComponent, ImageResizeDirective], | |
imports: [CommonModule], | |
exports: [ImageViewerComponent], | |
}) | |
export class ImageViewerModule {} |
NewerOlder