Skip to content

Instantly share code, notes, and snippets.

Avatar
💼
Working

Oliver Sahner osahner

💼
Working
View GitHub Profile
@osahner
osahner / safe.pipe.ts
Created Nov 10, 2018
angular Sanatizer Pipe
View safe.pipe.ts
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer, SafeHtml, SafeStyle, SafeScript, SafeUrl, SafeResourceUrl } from '@angular/platform-browser';
@Pipe({
name: 'safe'
})
export class SafePipe implements PipeTransform {
constructor(protected sanitizer: DomSanitizer) {}
public transform(value: any, type: string): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
@osahner
osahner / .htaccess
Created Jul 24, 2018
CORS Apache dynamic Access-Control-Allow-Origin
View .htaccess
<Directory "****">
SetEnvIf Origin "^http(s)?://.+$" AccessControlAllowOrigin=$0
Header always set Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
Header always set Access-Control-Allow-Credentials true env=AccessControlAllowOrigin
Header always set Access-Control-Allow-Methods "HEAD, POST, GET, OPTIONS, DELETE, PUT"
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
</Directory>
@osahner
osahner / InputWrapperDirective.ts
Created Dec 11, 2017
Angular Wrapper Directive
View InputWrapperDirective.ts
import { Directive, Renderer2, ElementRef, AfterViewInit } from '@angular/core'
@Directive({
selector: '[inputWrapper]'
})
export class InputWrapperDirective implements AfterViewInit {
constructor(private _renderer:Renderer2, private _el: ElementRef) {
}
@osahner
osahner / country-select.component.ts
Created Apr 21, 2017
angular2 bootstrap4 country select menu
View country-select.component.ts
import { Component, EventEmitter, Input, Output } from '@angular/core';
import * as iso3166 from 'iso-3166-2/iso3166.min';
@Component({
selector: 'app-country-select',
template: `
<select name="theme" [class]="'form-control' + (size ? ' form-control-' + size : '')"
[ngModel]="countryIsoCode" (ngModelChange)="change($event)">
<option *ngFor="let country of countries" [ngValue]="country.value">{{country.display}}</option>
@osahner
osahner / sortable-list.abstract.ts
Last active Jul 24, 2018
angular2 sortable list abstract class
View sortable-list.abstract.ts
import { ChangeDetectorRef } from '@angular/core';
/**
* @whatItDoes decorates Component with toggleOrder(property), get list() and get(CSS)Class functions.
*
* @howToUse
* \@Component({
* template: `
* <table>
* <tr>
@osahner
osahner / show-hide-password.component.ts
Last active Apr 21, 2017
angular2 bootstrap4 show/hide password input wrapper
View show-hide-password.component.ts
import {
Component, ElementRef, Input, OnInit, Renderer2
} from '@angular/core';
/**
* @whatItDoes Add show hide button to text/password input fields.
*
* @howToUse
* <show-hide-password size="sm|lg">
* <input type="password" name=... />