Skip to content

Instantly share code, notes, and snippets.

import { Injectable } from '@angular/core';
import { JwtHelperService } from '@auth0/angular-jwt';
import { interval } from 'rxjs/internal/observable/interval';
import { of } from 'rxjs/internal/observable/of';
import { map, startWith, switchMap } from 'rxjs/operators';
import { Observable } from 'rxjs/Rx';
import { LoginResponseVm, LoginVm, SecurityClient } from '../app.api';
import { LocalStorageService } from './local-storage.service';
@Injectable({
@dev-sampsonorson
dev-sampsonorson / load-module.directive.ts
Created June 14, 2023 08:45 — forked from nartc/load-module.directive.ts
Angular - LazyLoad non-route Module Directive
import {
Compiler,
ComponentRef,
Directive,
Inject,
Injector,
Input,
NgModuleFactory,
OnInit,
Type,
// API Service
export class ApiService {
get(parameters: SomeParameters): Observable<ReturnType> {
if (!this.validate(parameters)) {
// throw error on failed validation
throw new Error('Parameters do not pass validation');
}
return this.httpClient.get(...);
}
@NgModule({
imports: [OAuthModule.forRoot({...})] // <-- how to use the configuration.json here
})
export class AppModule {
constructor(@Inject(AppConfig) private readonly appConfig: AppConfiguration) {} // I can inject
}
@dev-sampsonorson
dev-sampsonorson / angular-cli-node-js-typescript-support.csv
Created June 14, 2023 08:42 — forked from nartc/angular-cli-node-js-typescript-support.csv
Angular CLI, Angular, Node.js and TypeScript compatibility.
Angular CLI version Angular version Node.js version TypeScript version
- 2.x 6.0.x or later minor version 2.0.x
1.0.6 4.x 6.9.x or later minor version 2.2.x
1.1.3 4.x 6.9.x or later minor version 2.3.x
1.2.7 4.x 6.9.x or later minor version 2.3.x
1.3.2 4.2.x or later minor version 6.9.x or later minor version 2.4.x
1.4.10 4.2.x or later minor version 6.9.x/8.9.x or later minor version 2.4.x
(1.5.6) 5.0.x 6.9.x/8.9.x or later minor version 2.4.x
1.5.6 5.1.x 6.9.x/8.9.x or later minor version 2.5.x
1.6.7 5.2.x or later minor version 6.9.x/8.9.x or later minor version 2.5.x
@dev-sampsonorson
dev-sampsonorson / multipleGitProfiles.md
Created March 16, 2022 16:59 — forked from Icaruk/multipleGitProfiles.md
How to have multiple profiles on git

Step 1

Go to your work folder, mine is located at: F:/Work/EnterpriseName/

And then create a .gitconfig-work with the following data:

@dev-sampsonorson
dev-sampsonorson / nx-structure-angular-nestjs.md
Created February 9, 2022 23:36 — forked from trungvose/nx-structure-angular-nestjs.md
Nx workspace structure for NestJS and Angular

Nx

https://nx.dev/

Nx is a suite of powerful, extensible dev tools to help you architect, test, and build at any scale — integrating seamlessly with modern technologies and libraries while providing a robust CLI, caching, dependency management, and more.

It has first-class support for many frontend and backend technologies, so its documentation comes in multiple flavours.

Principles

//--------------- ElementRef----------------------
@ViewChild('foo', {static: false}) foo: ElementRef;
@Component({
selector: 'sample',
template: `
@dev-sampsonorson
dev-sampsonorson / tinyfly.loading.js
Created September 23, 2011 17:02 — forked from tinyfly/tinyfly.loading.js
Add and remove loading animation to ajax calls (jQuery)
// This code depends on jQuery
//create 1 global variable for namespacing purposes.
if (typeof tinyfly === 'undefined') {
tinyfly = {};
}
/* Handles adding and removing loading animations for ajax calls */
tinyfly.loading = (function($) {
var defaults = {},