Skip to content

Instantly share code, notes, and snippets.

View NetanelBasal's full-sized avatar
🎯
Focusing

Netanel Basal NetanelBasal

🎯
Focusing
View GitHub Profile
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)) {
<div>
<h5>Courses</h5>
<ul cdkListbox>
<li cdkOption="angular">Angular</li>
<li cdkOption="react">React</li>
<li cdkOption="solid">Solid</li>
</ul>
</div>
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]
import { NgOptimizedImage, provideImgixLoader } from '@angular/common';
NgModule({
providers: [
provideImgixLoader("https://my.base.url/", {
ensurePreconnect: boolean
})
],
bootstrap: [AppComponent]
})
<!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">
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 -->
beforeEach(() => {
TestBed.configureTestingModule({
providers: [
provideRouterForTesting(
testRoutes,
withDebugTracing(),
withRouterConfig({ paramsInheritanceStrategy: 'always' })
),
],
});
import { provideRouter, withDebugTracing, withPreloading, ... } from '@angular/router';
bootstrapApplication(AppComponent, {
providers: [
provideRouter(
appRoutes,
withDebugTracing(),
withInMemoryScrolling(options?)
withDisabledInitialNavigation(),
withEnabledBlockingInitialNavigation(),
RouterModule.forRoot(appRoutes, {
enableTracing: true,
preloadingStrategy: Strategy,
...
})
<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)" />