Skip to content

Instantly share code, notes, and snippets.

View lucasconstantino's full-sized avatar
❄️
Working from the cold

Lucas Constantino Silva lucasconstantino

❄️
Working from the cold
View GitHub Profile
angular.module('app', []).directive('ngDebounce', function($timeout) {
return {
restrict: 'A',
require: 'ngModel',
priority: 99,
link: function(scope, elm, attr, ngModelCtrl) {
if (attr.type === 'radio' || attr.type === 'checkbox') return;
elm.unbind('input');
@lucasconstantino
lucasconstantino / script-loader.js
Last active January 2, 2016 15:39 — forked from jonathanstark/adding-js-programmatically.html
A simple function with no dependencies to load external javascripts. Features include:- Loading multiple scripts at once;- Callback function to execute once all scripts have loaded;- Optionally load scripts asynchronously;- Optionally define a DOM object where scripts will be inserted.
/**
* Snippet function to load external scripts.
* @param {[String, Array]} sources Array of sources to load.
* @param {[Functon]} callback A callback to run when all scripts have loaded.
* @param {[Boolean]} aasync Whether sources should be loaded
* asynchronously or not.
* @param {[Object]} appendTo Optionally provide a DOM object to append
* the script tags to.
*/
function scriptLoader(sources, callback, async, appendTo) {