Skip to content

Instantly share code, notes, and snippets.


Pete Bacon Darwin petebacondarwin

View GitHub Profile
Spine = require('spine')
class Survey extends Spine.Model
@configure 'Survey', 'name', 'title', 'description'
@hasMany 'questions', Question
@fromJSON: (objects) ->
return unless objects
if typeof objects is 'string'
View gist:2003785
Currently if you want to use a coffee script class for an AngularJS service
the syntax for the dependency injection is a bit clunky: you have to define
the dependencies in multiple places
class SomeServiceClass
constructor: (@$dep1, @$dep2)->
# Initialize the service
someMethod: ()=>
petebacondarwin /
Created Mar 13, 2012
Handlers in Angular Routes
.config(['$routeProvider', ($routeProvider)->
updateQuestionnaire = (scope, next)->
questionnaire = next.params.questionnaire ? ''
scope.$root.questionnaireId = questionnaire
updateQuestionnIndex = (scope, next)->
questionIndex = Number(next.params.questionIndex)
if questionIndex? and not isNaN(questionIndex)
scope.$root.questionIndex = questionIndex
View gist:2170671
angular.module('myApp', []).service('Partners', function($resource) {
return $resource({ ull:myUrl},function(Partners, rsrcMethod){
Partners.externalize = function(self) {
var myself = angular.copy(self);
return {data: myself};
Partners.query = rsrcMethod('', {response: ''});
petebacondarwin / index.html
Created Mar 27, 2012
AngularJS 1.0 - Masked Input Widget
View index.html
<input ng-model="" ui-mask='"(9999) 9999 9999"' placeholder="(01234)-5678-8901" required />
petebacondarwin / app.js
Created Oct 11, 2012 — forked from ggoodman/app.js
AngularJS@1.0.2 + Jasmine
View app.js
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$ = 'World';
View app.js
angular.module('onlineModule',[]).factory('dataService', { ... });
angular.module('offlineModule',[]).factory('dataService', { ... });
var app = angular.module('myApp', ['onlineModule']); // onlineModule or offlineModule
app.service('x', function (dataService) { // $dataService could be onlineModule.dataService or offlineModule.dataService
// online or offline? we don't care!
app.service('y', function (dataService) {
petebacondarwin / angular.js
Created Jun 26, 2013
Dynamic Script Tag Test
View angular.js
* @license AngularJS v1.0.7
* (c) 2010-2012 Google, Inc.
* License: MIT
(function(window, document, undefined) {
'use strict';

What is dgeni?

dgeni is a documentation generator developed by the Angular team. Ironically it lacks documentation right now, so we try to develop a very simple step-by-step-guide here, until a better documentation is available. Please share and fork this Gist.

dgeni is currently used in these project

Why should I use dgeni?

View gist:11264789
<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>
<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>