Skip to content

Instantly share code, notes, and snippets.

View aaronfrost's full-sized avatar
:octocat:
Software Architect Contractor

Aaron Frost aaronfrost

:octocat:
Software Architect Contractor
View GitHub Profile
@aaronfrost
aaronfrost / scopes.html
Last active August 29, 2015 14:05
Multiple Scopes - JS
<!--Parent Controller-->
<div ng-controller="ParentController">
<!--First Child Controller-->
<div ng-controller="ChildAController">
<button ng-click="handleClick()">Click This</button>
</div>
<!--Second Child Controller-->
<div ng-controller="ChildBController">
<button ng-click="handleClick()">Click This</button>
@aaronfrost
aaronfrost / scopes.html
Created August 16, 2014 20:09
Multiple Scopes
<!--Parent Controller-->
<div ng-controller="ParentController">
<!--First Child Controller-->
<div ng-controller="ChildAController">
<button ng-click="handleClick()">Click This</button>
</div>
<!--Second Child Controller-->
<div ng-controller="ChildBController">
<button ng-click="handleClick()">Click This</button>
@aaronfrost
aaronfrost / ngshowhide.html
Last active August 29, 2015 14:02
example of ng-show/ng-hide that is bad
<div class="big-section">
<div ng-if="archiveMode">
<div class="header">
<i class="archive-icon"></i>
</div>
<div>
<span>{{description}}</span>
</div>
<button ng-click="unarchive()">Unarchive</button>
</div>
@aaronfrost
aaronfrost / badNgClass.css
Last active August 29, 2015 14:02
an example of bad ng-classing
.item{
background-color:white;
color:black;
}
.item:hover{
background-color:black;
color:white;
}
@aaronfrost
aaronfrost / unwatch.js
Last active August 29, 2015 14:02
Gist for a watch discussion
angular.module('app').directive('MyDirective', function(){
//NEW AND IMPROVED, NOW WITH LESS WATCHING!
return {
restrict: 'AE',
replace: 'true',
templateUrl: '../../blah.html',
scope:{
item: '='
},
@aaronfrost
aaronfrost / debounce2.html
Last active August 29, 2015 14:02
Talk about Debounces
<div ng-controller="TestCtrl" >
<div test-ctrl-move-handler="doMouseMoveEvent()" style="width:1000px;height:1000px;"></div>
</div>
//In your Gruntfile
grunt.registerTask('replaceURL', '...', require('./urlReplacer.js'));
//Then in urlReplacer.js
var fs, r, oldfile, newfile;
fs = require('fs');
r = new RegExp("some regex to match your url", 'g');
//read the the file and replace the text
oldfile = fs.readFileSync(__dirname + '/file-with-url-that-needs-to-be-replaced.js', 'utf8');
newfile = oldfile.replace(r, 'http://thenewurl.com');
@aaronfrost
aaronfrost / letdemo.js
Created May 6, 2013 20:01
Demo that ES6 let scoping still allows for variable hoisting
//For more reading, check here: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Scope_Cheatsheet#let
//Try running these in the Scratchpad of Mozilla Firefox
//THIS IS NOT WHAT HAPPENS, BUT WHAT YOU ARE EXPECTING
(function(){
if(navigator){
console.log(b); //if let didn't hoist, this would throw an error #THIS IS NOT WHAT ACTUALLY HAPPENS
let b = 1;
<div id="foo">
<div class="bar">Baz</div>
</div>
@aaronfrost
aaronfrost / af11.js
Created March 23, 2013 07:55
Arrow Function - 11 - No parenthesis
//NONE
let add = () => 0 + 0; //0 params, parens required
//ONE PARAM
let add = x => x + x; //1 param, parens options
let add = (x) => x + x;
//MULTI PARAMS
let add = (x, y) => x + y; //multi params, parens required