Skip to content

Instantly share code, notes, and snippets.

View debugmodedotnet's full-sized avatar

Dhananjay Kumar debugmodedotnet

View GitHub Profile
// 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
debugmodedotnet / jspoland2020.js
Created November 20, 2020 17:17
code from jspoland2020 JavaScript talk
// // value of 'this' depends on how you are calling the function
var Dog = {
name :'foo',
eat : function(){
console.log(this);
}
}
import { Component, OnInit } from '@angular/core';
import { CourseCatalogService } from '../shared/coursecatalog.service';
import { NavigationExtras, Router, ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-catalog',
templateUrl: './catalog.component.html',
styleUrls: ['./catalog.component.css']
})
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
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;
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-learningapproach',
templateUrl: './learningapproach.component.html',
styleUrls: ['./learningapproach.component.scss']
})
export class LearningapproachComponent implements OnInit {
constructor() { }
public class UnityResolver : IDependencyResolver
{
protected IUnityContainer container;
public UnityResolver(IUnityContainer container)
{
if (container == null)
{
throw new ArgumentNullException("container");
}
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Description;
import { Component, OnInit, Input, ChangeDetectionStrategy, OnChanges, ChangeDetectorRef } from '@angular/core';
import { Observable } from 'rxjs';
import { TouchSequence } from 'selenium-webdriver';
@Component({
selector: 'app-child',
template: `
<h2>Items : {{_data.counter}} </h2>
<button (click)='0'>Refresh</button>
`,
import { EventEmitter, Component, OnInit, Input, OnChanges, ChangeDetectionStrategy, SimpleChange, Output } from '@angular/core';
@Component({
selector: 'app-child',
templateUrl:'app-child.component.html',
styleUrls: ['./app-child.component.css']