Skip to content

Instantly share code, notes, and snippets.

View ngohungphuc's full-sized avatar
🏡
Sài Gòn & Lelystad

Tony Ngo ngohungphuc

🏡
Sài Gòn & Lelystad
View GitHub Profile
import { Injectable } from "@angular/core";
import { ApplicationInsights } from "@microsoft/applicationinsights-web";
import {
ActivatedRouteSnapshot,
ResolveEnd,
Router,
NavigationStart,
NavigationEnd,
RouterEvent
} from "@angular/router";
@ViewChild(DynamicDirective) dynamic: DynamicDirective;
constructor(
private componentFactoryService: ComponentFactoryService
) {
}
ngOnInit(){
const dynamiCreateComponent = this.componentFactoryService.createComponent(TestComponent, this.dynamic);
import {
ComponentFactoryResolver,
Injectable,
ComponentRef
} from "@angular/core";
@Injectable()
export class ComponentFactoryService {
private componentRef: ComponentRef<any>;
constructor(private componentFactoryResolver: ComponentFactoryResolver) {}
<ng-template dynamic-ref></ng-template>
import { Directive, ViewContainerRef } from "@angular/core";
@Directive({
selector: "[dynamic-ref]"
})
export class DynamicDirective {
constructor(public viewContainerRef: ViewContainerRef) {}
}
private readonly IOptions<EmailSettings> _emailSetting;
public EmailSender(IOptions<EmailSettings> emailSetting)
{
_emailSetting = emailSetting;
}
email.From.Add(new MailboxAddress(_emailSetting.Value.SenderName, _emailSetting.Value.Sender));
services.Configure<EmailSettings>(configuration.GetSection("EmailSettings"));
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
@Injectable({
providedIn: 'root',
})
export class StorageService {
public static readonly TYPE_ACCESS_TOKEN: string = 'access_token';
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
})
export class HomeComponent implements OnInit {
constructor(private http: HttpClient) {
query PostQuery {
posts (id:10){
id
title
body
userId
comment {
id
email
body