How to display the app version in Angular?

If you want to use/show the version number in your angular app please do the following: Prerequisites: Angular file and folder structure created via Angular CLI Steps for Angular 6.1 (TS 2.9+) till Angular 11 In your /tsconfig.json (sometimes also necessary in /src/tsconfig.app.json) enable the following option (webpack dev server restart required afterwards): “compilerOptions”: { … Read more

Is there a way to remove unused imports and declarations from Angular 2+? [closed]

Edit (as suggested in comments and other people), Visual Studio Code has evolved and provides this functionality in-built as the command “Organize imports”, with the following default keyboard shortcuts: option+Shift+O for Mac Alt + Shift + O for Windows Original answer: I hope this visual studio code extension will suffice your need: https://marketplace.visualstudio.com/items?itemName=rbbit.typescript-hero It provides … Read more

How to add “class” to host element?

This way you don’t need to add the CSS outside of the component: @Component({ selector: ‘body’, template: ‘app-element’, // prefer decorators (see below) // host: {‘[class.someClass]’:’someField’} }) export class App implements OnInit { constructor(private cdRef:ChangeDetectorRef) {} someField: boolean = false; // alternatively also the host parameter in the @Component()` decorator can be used @HostBinding(‘class.someClass’) someField: … Read more

To enable or disable the input field based on the value of select component in angular

You have to do some editings. in your Html file <mat-form-field class=”id-name”> <mat-select placeholder=”ID Card” formControlName=”IDproof” (ngModelChange)=”onChange($event)”> <mat-option *ngFor=”let IDproof of IDproofs” [value]=”IDproof.value”> {{IDproof.viewValue}} </mat-option> <mat-option [value]=”‘disabled'”> {{‘disabled’}} </mat-option> </mat-select> </mat-form-field> And in your ts file onChange(data) { if(data && data != ‘disabled’){ this.myForm.get(‘idNum’).enable() }else{ this.myForm.get(‘idNum’).disable() } }

Array of formGroup within mat-table for each row

It’s difficult help if we can’t get access to the code. In this stackblitz I put a simple example. See that we create a form Array like myformArray = new FormArray([ new FormGroup({ name: new FormControl(“uno”), surname: new FormControl(“one”) }), new FormGroup({ name: new FormControl(“dos”), surname: new FormControl(“two”) }), new FormGroup({ name: new FormControl(“tres”), surname: … Read more