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 / app.js
Created April 29, 2017 19:41
load template for ng-include
// ng-include templates
require('angulartemplate!./foo/bar/includedtemplate.html');
require('angulartemplate!./foo/bar/anotherincludedtemplate.html');
// and so on
@aaronfrost
aaronfrost / myComponent.js
Last active April 29, 2017 19:01
templateUrl vs template
angular.module('app')
.component('myComponent', {
templateUrl: 'foo/bar/myComponent.html', // OLD WAY
controller: function(){
//controller code
}
});
angular.module('app')
@aaronfrost
aaronfrost / foo.js
Last active December 11, 2015 06:12
Show a defined property
var foo = {};
Object.defineProperty(a, "bar",{
get: getFoo,
set: setFoo
});
export default foo;
function getFoo(){
//do shiz
@aaronfrost
aaronfrost / service.js
Created September 30, 2015 17:38
caching service in Angular
angular.module('app').factory('myService', function($q, $http){
var data;
var dataPromise;
return {
getData: getData
}
function getData(){
//If the data is already here, return it in a resolved promise
@aaronfrost
aaronfrost / default.js
Created February 10, 2015 22:07
Default Questions
var x = "INIT";
function test(a = x) {
var x;
return a;
}
console.log( test() ); //undefined or 'INIT'
@aaronfrost
aaronfrost / bindonce.html
Last active August 29, 2015 14:07
Show Off Bind Once
<!--Pre-Angular 1.3-->
<p id="normal-binding-example">Normal binding: {{name}}</p>
<!--Angular 1.3-->
<p id="one-time-binding-example">One time binding: {{::name}}</p>
@aaronfrost
aaronfrost / let.js
Created September 10, 2014 08:36
let expression weirdness in FF
//I don't think that this is working right in Firefox
let c = let (a = getA()) a;
console.log(c, a); //Logs 1, 0
//Why did it log 0 for "a"?
function getA(){
return 1;
}
function getB(){
return 2;
@aaronfrost
aaronfrost / let.js
Created September 10, 2014 07:55
Is this how LET should work?
let a = 0;
{
console.log(a); //Node throws error cause "a" isn`t defined yet, but it was defined on line one.
let a = 1;
console.log(a);
}
console.log(a);
@aaronfrost
aaronfrost / undeclared.js
Last active August 29, 2015 14:06
Do I Call This "Undeclared"?
var a;
console.log(a); //Logs 'undefined'
console.log(b); //ReferenceError: 'b' is not defined
/**
* Neither are defined, but only the undeclared variable gets an 'undefined' error.
*
* So, is the correct idiom 'undeclared' when referring to an instruction that will throw
* a ReferenceError because it wasn`t declared? Or is there another idiom that I should use?
*
@aaronfrost
aaronfrost / dataModel.js
Created September 8, 2014 17:19
Angular - Rich Data Model Pattern
angular.module('app').run(function($q, $timeout){
function User(data){
if(this == window)return new User(data);
angular.extend(this, data);
}
User.prototype.sayHi = function(){
console.log("HI!!!");