Skip to content

Instantly share code, notes, and snippets.

Zhen Deng ZhenDeng

Block or report user

Report or block ZhenDeng

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Warn user of unsaved changes before leaving page
import { ComponentCanDeactivate } from './pending-changes.guard';
import { HostListener } from '@angular/core';
import { Observable } from 'rxjs/Observable';
export class MyComponent implements ComponentCanDeactivate {
// @HostListener allows us to also guard against browser refresh, close, etc.
canDeactivate(): Observable<boolean> | boolean {
View Pipe Implementation
Pipe File:
import { Pipe, PipeTransform } from '@angular/core';
name: 'TableFilterMultiple'
export class TablefilterMultiplePipe implements PipeTransform {
transform(items: any[], fields: any[], value: string): any[] {
View table template
body {
font-family: 'Segoe UI' !important;
width: 900px;
margin: 0 auto;
background-color: #E7E6E3;
padding: 15px;
View verify request header value
Request.Headers.TryGetValue("some-header-name", out var headers);
if(headers.Count > 1 || string.IsNullOrWhiteSpace(headers.FirstOrDefault())){
return new UnauthorizedResult();
View ng-select search
View solve autofill issue in material autocomplete
import { Component, Inject, ViewChild } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { MatAutocompleteTrigger } from '@angular/material';
template: `
View bind event using directive
import { Directive, ElementRef, HostListener } from '@angular/core';
import { Router } from '@angular/router';
selector: '[routeTransformer]'
export class RouteTransformerDirective {
constructor(private el: ElementRef, private router: Router) { }
View angular material snack bar design and implementation
Toast Component
<div class="toast">
<div class="toast-icon">
<i class="far fa-times-circle" *ngIf="data?.type=='Error'"></i>
<i class="far fa-check-circle" *ngIf="data?.type=='Success'"></i>
<i class="fas fa-exclamation-triangle" *ngIf="data?.type=='Warning'"></i>
<i class="fas fa-info-circle" *ngIf="data?.type=='Info'"></i>
View Service file
public ExcelPackage AddWorksheetForCarts(ExcelPackage pck, int cartId, string CartName)
// Create Headers
string[] headerList = { "Cart Name", "Parent Code", "Stock Code", "Item Desc", "RRP (Ex tax)", "RRP (Inc tax)", "Reseller Price(Ex tax)", "Quantity", "Subtotal (Ex tax)" };
// Capture Number Of Columns
// We'll Use This Later When Creating Rows
int iColCount = headerList.Length;
ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Cart Name:" + CartName);
You can’t perform that action at this time.