Skip to content

Instantly share code, notes, and snippets.

View timkindberg's full-sized avatar

Tim Kindberg timkindberg

View GitHub Profile
@timkindberg
timkindberg / app.js
Last active October 22, 2015 18:04
ng-forward ng1 migration (before)
angular.module('app', []);
@timkindberg
timkindberg / app.js
Last active May 11, 2016 16:04
ng-forward ng1 migration (after)
import { Component, bundle } from 'ng-forward';
import { ComponentA } from './component-a';
import { ComponentB } from './component-b';
@Component({
selector: 'app',
directives: [ ComponentA, ComponentB ]
})
export class App { }
@timkindberg
timkindberg / mockDirective.js
Last active August 29, 2015 14:26
Quickly Mock Child Components
export function mockDirective(...names) {
return angular.mock.module(($compileProvider) => {
names.forEach((name) => {
$compileProvider.directive(name, () => {
return {
priority: 9999,
terminal: true,
restrict: 'EAC',
template:`<mock-${dashCase(name)}></mock-${dashCase(name)}>`,
replace: true
@timkindberg
timkindberg / placeholder.js
Created January 25, 2013 18:28
JQuery polyfill for input placeholders.
;(function($){
var alreadySupported = 'placeholder' in document.createElement('input');
function doPlaceholder(){
if(alreadySupported) return;
var $this = $(this);
if($this.data('placeholder-polyfill'))return;
$this.data('placeholder-polyfill', true);
if(!$this.is('[type="text"], [type="password"], [type="email"], textarea')) return;
$this.wrap('<span style="position:relative" />');