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 class Store<State extends Record<string, any>> { | |
private subscribers = new Set<Subscriber<State>>(); | |
constructor(private state: State) { } | |
getValue() { | |
return this.state; | |
} | |
setValue(newState: State | ((state: State) => State)) { |
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
<div> | |
<h5>Courses</h5> | |
<ul cdkListbox> | |
<li cdkOption="angular">Angular</li> | |
<li cdkOption="react">React</li> | |
<li cdkOption="solid">Solid</li> | |
</ul> | |
</div> |
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 { ImageLoaderConfig, IMAGE_LOADER, NgOptimizedImage } from '@angular/common'; | |
@NgModule({ | |
providers: [{ | |
provide: IMAGE_LOADER, | |
useValue: (config: ImageLoaderConfig) => { | |
return `https://example.com/images?src=${config.src}&width=${config.width}` } | |
} | |
], | |
bootstrap: [AppComponent] |
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 { NgOptimizedImage, provideImgixLoader } from '@angular/common'; | |
NgModule({ | |
providers: [ | |
provideImgixLoader("https://my.base.url/", { | |
ensurePreconnect: boolean | |
}) | |
], | |
bootstrap: [AppComponent] | |
}) |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>MyNgApp</title> | |
<base href="/"> | |
<!-- 👇🏻 👇🏻 👇🏻 👇🏻 👇🏻 👇🏻 --> | |
<link rel="preconnect" href="https://picsum.photos"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> |
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 { NgOptimizedImage } from '@angular/common'; | |
@Component({ | |
standalone: true, | |
imports: [NgOptimizedImage], | |
template: ` | |
<!-- above the fold --> | |
<img rawSrc="https://picsum.photos/200/300" width="200" height="300" priority /> | |
<!-- below the fold --> |
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
beforeEach(() => { | |
TestBed.configureTestingModule({ | |
providers: [ | |
provideRouterForTesting( | |
testRoutes, | |
withDebugTracing(), | |
withRouterConfig({ paramsInheritanceStrategy: 'always' }) | |
), | |
], | |
}); |
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 { provideRouter, withDebugTracing, withPreloading, ... } from '@angular/router'; | |
bootstrapApplication(AppComponent, { | |
providers: [ | |
provideRouter( | |
appRoutes, | |
withDebugTracing(), | |
withInMemoryScrolling(options?) | |
withDisabledInitialNavigation(), | |
withEnabledBlockingInitialNavigation(), |
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
RouterModule.forRoot(appRoutes, { | |
enableTracing: true, | |
preloadingStrategy: Strategy, | |
... | |
}) |
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
<input (keydown.shift.k)="onKeydown($event)" /> | |
<input (keydown.k)="onKeydown($event)" /> | |
<input (keydown.code.keyk)="onKeydown($event)" /> | |
<input (keydown.code.shift.alt.Period)="onKeydown($event)" /> | |
<input (keydown.meta.k)="onKeydown($event)" /> |