Skip to content

Instantly share code, notes, and snippets.

View oleersoy's full-sized avatar

Ole Ersoy oleersoy

  • Firefly Semantics Corporation
  • Chicago
View GitHub Profile
@oleersoy
oleersoy / search.ts
Last active September 26, 2019 02:08
const { isArray } = Array;
function search(entries: any[], search: string) {
search = search.toLowerCase();
return entries.filter(function (obj) {
const keys: string[] = Object.keys(obj);
return keys.some(function (key) {
const value = obj[key];
const posts: Post[] =
[
{
title: "Filtering Objects",
content: "We have an ...",
tags: ['javascript', 'filtering']
},
{
title: "Searching an Array of Dates",
content: "We have a text input='11/25/2014'",
import { Injectable } from '@angular/core';
import {
Resolve,
ActivatedRouteSnapshot,
RouterStateSnapshot } from '@angular/router';
import { Post } from './post.model';
import { HttpClient } from '@angular/common/http';
@Injectable({
providedIn: 'root'
@oleersoy
oleersoy / routes.ts
Last active September 15, 2019 17:37
<mat-sidenav #sidenav>
<mat-nav-list>
<a mat-list-item (click)="sidenav.toggle()" *ngFor="let route of routes" [routerLink]="route.path"> {{route.label}}</a>
</mat-nav-list>
</mat-sidenav>
Type '({ path: string; redirectTo: string; pathMatch: string; } | { path: string; component: typeof HomeComponent; } | { path: string; canActivate: string; component: typeof LoginComponent; })[]' is not assignable to type 'Route[]'.
Type '{ path: string; redirectTo: string; pathMatch: string; } | { path: string; component: typeof HomeComponent; } | { path: string; canActivate: string; component: typeof LoginComponent; }' is not assignable to type 'Route'.
Type '{ path: string; canActivate: string; component: typeof LoginComponent; }' is not assignable to type 'Route'.
Types of property 'canActivate' are incompatible.
Type 'string' is not assignable to type 'any[]'.
getEmailError() {
if (this.email.hasError('email')) {
return 'Please enter a valid email address.';
}
if (this.email.hasError('required')) {
return 'An Email is required.';
}
}
mdq: MediaQueryList;
mediaQueryListener:()=>void;
constructor( changeDetectorRef: ChangeDetectorRef, media: MediaMatcher ) {
this.mdq = media.matchMedia('(max-width: 992px)');
this.mediaQueryListener = () => changeDetectorRef.detectChanges();
this.mdq.addListener(this.mediaQueryListener);
}
let o1:Observable<boolean> = this.cb1.valueChanges;
let o2:Observable<boolean> = this.cb2.valueChanges;
merge(o1, o2).subscribe( v=>{
this.columnDefinitions[0].hide = this.cb1.value;
this.columnDefinitions[1].hide = this.cb2.value;
console.log(this.columnDefinitions);
});
}
ngAfterViewInit() {
let o1:Observable<boolean> = this.cb1.valueChanges;
let o2:Observable<boolean> = this.cb2.valueChanges;
merge(o1, o2).subscribe( v=>{
let cb1Value = this.cb1.value;
let cb2Value = this.cb2.value;
this.cbValues = {
cb1: cb1Value,
.mat-header-cell {
flex-direction: column;
justify-content: center;
}
.mat-cell {
text-align: center;
justify-content:center;
}