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';
public class TerminateCourseService : ITerminateCourseService
{
public IVisaTerminationWorkflowService _visaTerminationWorkflow { get; set; }
public TerminateCourseService()
{
}
public ITerminationWorkflowService GetTerminationWorkflow(TerminationReason terminationReason) // because IVisaTerminationWorkflowService inherit from ITerminationWorkflowService
{
C#: public Dictionary<string, string> ExtensionData { get; set; }
Angular Model: ExtensionData: { [key: string]: string };
Implementation: this.worktrayItem.ExtensionData.SchoolTerm
@ZhenDeng
ZhenDeng / Child Component
Last active May 6, 2021 01:59
This snippet is used for one parent component with html and render different child component in html, could run different function body based on which child component being rendered
@Component({
selector: 'app-school-year-change',
templateUrl: './school-year-change.component.html',
styleUrls: ['./school-year-change.component.scss']
})
export class SchoolYearChangeComponent extends WorktrayComponentBase implements OnInit {
private _footerButtons: FooterButton[];
constructor(private ref: DynamicDialogRef) {
sudo chown -R $USER /usr/local/lib/node_modules
public async Task<int> AutoCreateWelfareManagementWorkTrayItems(int defaultRunTerm, int defaultRunWeek)
{
async Task<int> Func()
{
return worktrayItemsCreatedCount;
}
return await ExecuteAsync(Func);
}
public async Task<ServiceResponse<int>> TerminateCourse(DateTime dateTime)
**** send data to component via resolver
1. create resolver file -- ate-resolver.service.ts
import {Injectable, Inject} from '@angular/core';
import {Resolve, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
import { Observable } from 'rxjs';
import { APP_CONFIG, IAppConfig } from '../../config/app.config';
import { DataContextService } from 'src/app/service/datacontext.service';