Skip to content

Instantly share code, notes, and snippets.

View petebacondarwin's full-sized avatar

Pete Bacon Darwin petebacondarwin

View GitHub Profile
<form ng-message-include="form-messages">
<input class="form-control" type="text" name="first_name" id="input_first_name" ng-model="data.first_name" required />
<div class="error-messages" ng-if="interacted(my_form.first_name)" ng-message="my_form.first_name.$error">
<div ng-message-on="required">You did not enter your first name</div>
</div>
<input class="form-control" type="text" name="last_name" id="input_last_name" ng-model="data.last_name" required />
<div class="error-messages" ng-if="interacted(my_form.last_name)" ng-message="my_form.last_name.$error">
<div ng-message-on="required">You did not enter your last name</div>
</div>
@petebacondarwin
petebacondarwin / index.html
Created September 3, 2014 10:06
AngularJS $location HTML5 mode "local" URLs
<!DOCTYPE html>
<html>
<head>
<title></title>
<script>
var e = document.createElement("base");
e.setAttribute("href",location.pathname);
console.log(location.pathname);
document.head.appendChild(e);
</script>
/**
* @license AngularJS v1.3.2-local+sha.91834bc
* (c) 2010-2014 Google, Inc. http://angularjs.org
* License: MIT
*/
(function(window, angular, undefined) {'use strict';
/**
* @ngdoc module
* @name ngRoute
@petebacondarwin
petebacondarwin / app.js
Created December 15, 2014 14:03
Suggested extendable $http configuration...
angular.module('resources', [])
// So we create a new service for each configuration of $http that we want
.factory('myServerAPI', function($http) {
function customRequestTransform(value) { ... }
function customResponseTransform(value) { ... }
// Provide a configuration object that corresponds to our specific $http needs
@petebacondarwin
petebacondarwin / app.js
Created January 25, 2015 01:09
IE9 Memory Leak
'use strict';
var app = angular.module('myApp', [
'ngRoute'
]);
app.run(function ($rootScope, $location) {
var myArray = [];
for (var i = 0; i < 500; i++) {
@petebacondarwin
petebacondarwin / gist:020c78b256dc6d04b5a0
Last active August 29, 2015 14:20
Lazy Loading ...
index.html
<div ng-include="templateUrl"></div>
template1.html
<h1>Hello</h1>
<!DOCTYPE html>
<html>
<body>
<template id='my-component-template'>
<style>
@import url('whatever...');
</style>
</template>
@petebacondarwin
petebacondarwin / angular2.d.ts
Created July 14, 2015 13:45
Latest Angular 2 type definition
// Type definitions for Angular v2.0.0-local_sha.7dc1dff
// Project: http://angular.io/
// Definitions by: angular team <https://github.com/angular/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// ***********************************************************
// This file is generated by the Angular build process.
// Please do not create manual edits or send pull requests
// modifying this file.
// ***********************************************************
[ 'angular2/annotations : module',
'angular2/annotations/ComponentAnnotation.changeDetection : member',
'angular2/annotations/ComponentAnnotation.viewInjector : member',
'angular2/annotations/ComponentAnnotation.constructor : member',
'angular2/annotations/ComponentAnnotation : class',
'angular2/annotations/DirectiveAnnotation.selector : member',
'angular2/annotations/DirectiveAnnotation.properties : member',
'angular2/annotations/DirectiveAnnotation.events : member',
'angular2/annotations/DirectiveAnnotation.host : member',
'angular2/annotations/DirectiveAnnotation.lifecycle : member',
@petebacondarwin
petebacondarwin / survey.coffee
Created January 9, 2012 21:31
Spine Nested Models
Spine = require('spine')
require('spine/lib/relation')
class Survey extends Spine.Model
@configure 'Survey', 'name', 'title', 'description'
@hasMany 'questions', Question
@fromJSON: (objects) ->
return unless objects
if typeof objects is 'string'