随笔分类 - Angular
摘要:Service: fromObservable & fromSignalcan transform observable to and from signals. import { HttpClient, HttpErrorResponse } from '@angular/common/http'
阅读全文
摘要:Provide application level module in bootstrapApplication bootstrapApplication(AppComp, { providers: [ importProvidersFrom(HttpClinetModule) ] }) //BAD
阅读全文
摘要:{ path: 'admin', // load standalone component loadComponent: () => import('./feature/admin/admin.component').then(c => c.AdminComponent), // Swap User
阅读全文
摘要:Before v14, we do DI like this: @Component({ name: 'app-root', template: `<h1>Hello!</h1>` }) export class AppComponent { constructor(private http: Ht
阅读全文
摘要:There are two async exection context: Microtask Queue - ASAP (Promises, MutationObserver) Macrotask Queue - DO Later (setTimeout, setInterval, request
阅读全文
摘要:There are many ways to expose data to components, but based on different usecase, different solution has PROS & CONS. 1. ShareReplay(1) PROS: ShareRep
阅读全文
摘要:Some basic exmaple on Doc: https://material.angular.io/cdk/overlay/overview <!-- This button triggers the overlay and is it's origin --> <button (clic
阅读全文
摘要:In this lesson we're diving a bit deeper and learn how to inject services into Formly Extensions with the example of using ngx-translate to localize a
阅读全文
摘要:When you use TypeScript's --strictNullChecks flag, you can prevent the type checker from throwing an error with Angular's non-null assertion operator,
阅读全文
摘要:Sometimes a binding expression triggers a type error during AOT compilation and it is not possible or difficult to fully specify the type. To silence
阅读全文
摘要:
阅读全文
摘要:Let's say we have a date picker compoent which display start date and end date. We want to make sure that start date is no later than end date, if it
阅读全文
摘要:Define an action to update the record: import { createAction, props } from "@ngrx/store"; import { Update } from "@ngrx/entity"; import { Course } fro
阅读全文
摘要:Reducer: import { Course, compareCourses } from "../model/course"; import { EntityState, createEntityAdapter } from "@ngrx/entity"; import { createRed
阅读全文
摘要:npm install cookies-js --save import {Component, OnInit} from '@angular/core'; import {FormGroup, FormBuilder, Validators} from "@angular/forms"; impo
阅读全文
摘要:// course-detail.resolver.ts import {Resolve, ActivatedRouteSnapshot, RouterStateSnapshot} from "@angular/router"; import {Course} from "../shared/mod
阅读全文
摘要:For example we want to build pipe to sanitizer the url: @Pipe({ name: 'safeUrl' }) export class SafeUrlPipe implements PipeTransform { constructor(pri
阅读全文
摘要:Today modern browsers added native support for lazy loading images, and we can benefit from it by adding one simple attribute to our img element: <img
阅读全文
摘要:
阅读全文