ng-true-value ng-false-value alternative in Angular
In AngularJs (1.x) there is facility to set true value and false value for input type checkbox using ngTrueValue ngFalseValue directives. But its been removed in Angular 2 + . Below is directive which will serve the same purpose as it was in AngularJs (1.x) . Here it simply listens to the change event of input element using HostListener and value of input element is manipulated based on whether its checked or unchecked. import { Directive, Input, forwardRef, HostListener, ElementRef, Renderer2} from '@angular/core';import { ControlValueAccessor, NG_VALUE_ACCESSOR, NgControl} from '@angular/forms';@Directive({ selector: 'input[type=radio][trueFalseValue]', providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => TrueFalseValueDirective), multi: true } ]})export class TrueFalseValueDirective implements ControlValueAccessor { private propagateChange = (_: an