Skip to content

Instantly share code, notes, and snippets.

View darlanalves's full-sized avatar
🏠
Writing some code when I'm not busy writing code

Darlan Alves darlanalves

🏠
Writing some code when I'm not busy writing code
View GitHub Profile
@darlanalves
darlanalves / bindonce.js
Created August 5, 2014 04:25
A naive implementation of ng-bindonce
angular.module('ng').directive('ngBindonce', function() {
return function bindOnce($scope, $element, $attrs) {
var removeWatcher = $scope.$watch($attrs.ngBindOnce, function(value) {
if (value === undefined) return;
$element.text(value);
removeWatcher();
});
};
});
var gulp = require('gulp'),
concat = require('gulp-concat'),
wrap = require('gulp-wrap'),
multipipe = require('multipipe'),
spaceRe = /\s+/g,
wrapper = '(function(undefined){\n\n<%= contents %>\n}());';
module.exports = function buildModule(src, dest, watch) {
var name = String(src).replace(spaceRe, '-');
(function() {
function only(propertiesToKeep){
var object = this;
if (object === window) return object;
Object.keys(object).forEach(function(key) {
if (propertiesToKeep.indexOf(key) === -1) delete object[key];
});
/*
* Exemplo:
* var users = [
* {name: 'Victor Queiroz'},
* {name: 'João Bosco'},
* {name: 'Ruan Jordão'}
* ];
*
* Aplicando o filtro:
* {{ users | pluck:'name' | join:', ' }}