Skip to content

Instantly share code, notes, and snippets.

HTML:
<input type="submit" class="btn btn-login register-submit" (click)="keyboardFocus(focusChange)" value="Stay on the page" #focusChange>
Component:
@ViewChild('focusChange') elChange: ElementRef;
setTimeout(() => {
this.elChange.nativeElement.focus();
**** HTML
** Important: add tabindex="-1" to child tag
<button id="btn" class="btn" type="button">
<span class="btn__content" tabindex="-1">
I'm a button!
</span>
</button>
<a class="btn" href="#x">
<span class="btn__content" tabindex="-1">
@ZhenDeng
ZhenDeng / create custom provider
Created January 16, 2020 06:09
Using create custom MatSortHeaderIntl intance to modify the labels and text displayed as an example
*** In app module providers
{ provide: MatSortHeaderIntl, useClass: CustomMatSortHeaderIntl }
*** custom-mat-sort-header-intl.ts
create custom-mat-sort-header-intl.ts and in the file:
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs/internal/Subject';
sudo chown -R $USER /usr/local/lib/node_modules
1. in module provider
{ provide: APP_CONFIG, useValue: AppConfig }
2. app.config.ts
import { InjectionToken } from "@angular/core";
import { IAuthConfig } from "../service/Authentication/auth.config";
import { environment } from 'src/environments/environment';
1. Right Clicked on My Computer (windows)
2. Selected Advanced System Settings
3. Clicked "Environment Variables"
4. Under "Path" variable, made the FIRST value listed %AppData%\npm
***Component:
import { ComponentCanDeactivate } from './pending-changes.guard';
import { HostListener } from '@angular/core';
import { Observable } from 'rxjs/Observable';
export class MyComponent implements ComponentCanDeactivate {
// @HostListener allows us to also guard against browser refresh, close, etc.
@HostListener('window:beforeunload')
canDeactivate(): Observable<boolean> | boolean {
ngAfterViewInit() {
setTimeout(() => {
});
}
Pipe File:
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'TableFilterMultiple'
})
export class TablefilterMultiplePipe implements PipeTransform {
transform(items: any[], fields: any[], value: string): any[] {