how to reset in Angular

The jQuery solution that @dhaval-marthak posted in the comments obviously works, but if you look at the actual jQuery call it’s pretty easy to see what jQuery is doing, just setting the value attribute to an empty string. So in “pure” JavaScript it would be: document.getElementById(“uploadCaptureInputFile”).value = “”;

How to call a function on every route change in angular2

you can call activate method from main router-outlet like this <router-outlet (activate)=”changeOfRoutes()”></router-outlet> which will call every time when route will change. Update – Another way to achieve the same is to subscribe to the router events even you can filter them out on the basis of navigation state may be start and end or so, …

Read more

“Edit / Delete” button for each row & header column is ‘Action’ in the md-table component

You are on the right track, you just need to add an actions item to displayedColumns list: displayedColumns = [“username”, “email”, “userFirstName” … , “actions”]; and: <ng-container cdkColumnDef=”actions”> <md-header-cell > Actions </md-header-cell> <md-cell *cdkCellDef=”let row” > <button md-raised-button >Edit</button> </md-cell> </ng-container>

Styles in component for D3.js do not show in angular 2

Update Angular and SASS agreed on supporting ::ng-deep (instead of >>> or /deep/) a while ago until ::slotted or whatever makes it into browser standards becomes available in all browsers. ViewEncapsulation.Emulated (default) That’s by design. Angular adds class names unique to components and rewrites the added styles to only apply to the components where they …

Read more

How to disable selection of cells in ag-grid?

Note that if we set gridOption.suppressCellSelection = true we can disable cell selection for all columns’ cells. Here the question is regarding not showing a specific column’s cell’s highlighted border when it is selected. You can achieve this by bit of CSS and cellClass property of ColDef. You’ll need to add below CSS. .ag-cell-focus,.ag-cell-no-focus{ border:none …

Read more

Debounce @HostListener event

I would leverage debounce method decorator like: export function debounce(delay: number = 300): MethodDecorator { return function (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) { const timeoutKey = Symbol(); const original = descriptor.value; descriptor.value = function (…args) { clearTimeout(this[timeoutKey]); this[timeoutKey] = setTimeout(() => original.apply(this, args), delay); }; return descriptor; }; } and use it …

Read more

Angular 2 select option (dropdown) – how to get the value on change so it can be used in a function?

My answer is little late but simple; but may help someone in future; I did experiment with angular versions such as 4.4.3, 5.1+, 6.x, 7.x, 8.x, 9.x, 10.x, 11.x, 12.x, 13.x, 14.x using $event (latest at the moment) Template: <select (change)=”onChange($event)”> <option *ngFor=”let v of values” [value]=”v.id”>{{v.name}}</option> </select> TS export class MyComponent { public onChange(event): …

Read more

Ionic 4 custom components

Finally figured this out, here’s a repro that works: ionic start myProject blank –type=angular ionic g module components ionic g component components/myComponent –export This adds both a declaration and export to the components module for “myComponent”. To use the component just add ComponentsModule to your imports in your page module, e.g. @NgModule({ imports: [ CommonModule, …

Read more