@Optional dependency in Angular

Usage of @Optional (optional dependency), for example when LoginComponent is used as dialog or standalone. import { Optional } from ‘@angular/core’;   constructor( @Optional() private dialogRef: MatDialogRef<LoginComponent>, ) { … } import { Optional } from ‘@angular/core’; constructor( @Optional() private dialogRef: MatDialogRef<LoginComponent>, ) { … }

Reactive Form: previous value

let form = this.fb.group({ ‘hotelLocation’:[null] });   form.get(’hotelLocation’).valueChanges.subscribe(v => {   // HERE !! let prevVal = this.form.value[’hotelLocation’]; });let form = this.fb.group({ ‘hotelLocation’:[null] }); form.get(‘hotelLocation’).valueChanges.subscribe(v => { // HERE !! let prevVal = this.form.value[‘hotelLocation’]; });

@DateTimeFormat usage example

@GetMapping("/find") public Page<ReportProjection> reports( @RequestParam(required = false, name = "status") ReportStatus status, @RequestParam(required = false, name = "search") String search, @DateTimeFormat(pattern="yyyy-MM-dd") @RequestParam(required = false, name = "from") Date from, @DateTimeFormat(pattern="yyyy-MM-dd") @RequestParam(required = false, name = "to") Date to, Pageable pageable) { return reportService.reports(status, search, from, to, pageable); }@GetMapping("/find") public Page<ReportProjection> reports( @RequestParam(required = false, name Read more about @DateTimeFormat usage example[…]

SpEL in @Query (Spring Data)

@Query("select t from Test t where name = :#{#data.name} and type = :#{#data.type}") List<User> findByData(@Param("data") Data data);   public class Data { private String name; private DataType type; }@Query("select t from Test t where name = :#{#data.name} and type = :#{#data.type}") List<User> findByData(@Param("data") Data data); public class Data { private String name; private DataType type; Read more about SpEL in @Query (Spring Data)[…]

@ViewChild

@ViewChild can access only local template of component, not parent or child components. @Component({ selector: ‘app-login’, template: ` <re-captcha></re-captcha> <div #refname></div> `, styleUrls: [’./login.component.css’] }) export class LoginComponent implements OnInit, AfterViewInit {   @ViewChild(RecaptchaComponent) reCaptcha: RecaptchaComponent; @ViewChild(’refname’) input: ElementRef;   constructor() { console.log(this.reCaptcha); // null }   ngAfterViewInit(): void { console.log(this.reCaptcha); // not null } Read more about @ViewChild[…]

find & grep

Find ‘text to find‘ in *.xml files case-insensitive Method 1: grep -ir –include \*.xml ‘text to find’grep -ir –include \*.xml ‘text to find’ Method 2: find -name ‘*.xml’ -exec grep -i ‘text to find’ {} \;find -name ‘*.xml’ -exec grep -i ‘text to find’ {} \;