Skip to content

Instantly share code, notes, and snippets.


Dhananjay Kumar debugmodedotnet

View GitHub Profile
View mat.ts
import { NgModule } from '@angular/core';
import { A11yModule } from '@angular/cdk/a11y';
import { ClipboardModule } from '@angular/cdk/clipboard';
import { DragDropModule } from '@angular/cdk/drag-drop';
import { PortalModule } from '@angular/cdk/portal';
import { CdkStepperModule } from '@angular/cdk/stepper';
import { CdkTableModule } from '@angular/cdk/table';
import { CdkTreeModule } from '@angular/cdk/tree';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { MatBadgeModule } from '@angular/material/badge';
View a.json
const products : IProductDetails[] = [
Id: 1,
Title: 'Pen',
Price: 100
Qyanity: 100,
Color: "Red",
View thisinjs.js
function Product(title,price){
this.title = title;
this.price = price;
// call a function as method - MIP
// value of this inside function - always object before dot
View delete.js
let c1 = data.findIndex( t => Object.keys(t)[0] == d.type);
if(c1 > -1){
if(data[c1][d.type].length >1){
const index = data[c1][d.type].indexOf(d.title);
if (index > -1) {
data[c1][d.type].splice(index, 1);
const index = data[c1][d.type].indexOf(d.title);
View code.js
private filterDataSource: BehaviorSubject<Array<any>> = new BehaviorSubject([]);
public filterData = this.filterDataSource.asObservable();
updateUserData(data) {;
addData(dataObj) {
const currentValue = this.filterDataSource.value;
View a.js
// This service acts performs various actions such with Azure AD B2C
// It use an external library MSAL.JS minumim version 1.4. Check package.json
// Modify environment.ts file to update client id, tenant , policy etc. on changes in Azure portal
// First draft by - Dhananjay Kumar in Sprint 0
// Last modified by - Dhananjay Kumar in Sprint 0
// Unit Test - 0
import { Inject, Injectable } from '@angular/core';
declare var Msal: any;
import { environment } from 'src/environments/environment';
debugmodedotnet / jspoland2020.js
Created Nov 20, 2020
code from jspoland2020 JavaScript talk
View jspoland2020.js
// // value of 'this' depends on how you are calling the function
var Dog = {
name :'foo',
eat : function(){
View paginatior.ts
import { Component, OnInit } from '@angular/core';
import { CourseCatalogService } from '../shared/coursecatalog.service';
import { NavigationExtras, Router, ActivatedRoute } from '@angular/router';
selector: 'app-catalog',
templateUrl: './catalog.component.html',
styleUrls: ['./catalog.component.css']
View talk.txt
Title: Simplifying Dependency Injection in Angular
Dependency Injection is one of the most famous architecture patterns to create a scalable application that has loosely coupled entities such as classes. Application made using the DI pattern is highly loosely coupled, and any part such as the business logic layer of application can be replaced at the run time without affecting the presentation layer. By design Angular framework supports dependency injection. It enables you to inject dependencies such as services without writing your own DI container or refereeing to any third-party libraries.
You create a service in Angular to share data and operations between components, directives etc. Mainly services are used to achieve separation of concerns and reusability. You keep operations such as API calls, logging, client-side data manipulations, etc. in a service. One of the significant purposes of creating service is to keep component clean that focuses on user interaction and presentations.
So, if you create
View gist:dee70a3e3b13a92b8d216deb4db69fe1
const domino = require('domino');
//const domino = require('@angular/platform-server/node_modules/domino');
const fs = require('fs');
const path = require('path');
const template = fs.readFileSync('dist/active-directory-javascript-singlepageapp-angular/browser/index.html').toString();
const win = domino.createWindow(template);
global['window'] = win;
global['document'] = win.document;
global['DOMTokenList'] = win.DOMTokenList;
global['Node'] = win.Node;