Skip to content

Instantly share code, notes, and snippets.

View petebacondarwin's full-sized avatar

Pete Bacon Darwin petebacondarwin

View GitHub Profile

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?

@petebacondarwin
petebacondarwin / angular.js
Created June 26, 2013 10:48
Dynamic Script Tag Test
/**
* @license AngularJS v1.0.7
* (c) 2010-2012 Google, Inc. http://angularjs.org
* License: MIT
*/
(function(window, document, undefined) {
'use strict';
////////////////////////////////////
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
petebacondarwin / app.js
Created October 11, 2012 14:01 — forked from ggoodman/app.js
AngularJS@1.0.2 + Jasmine
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
});
@petebacondarwin
petebacondarwin / index.html
Created March 27, 2012 12:23
AngularJS 1.0 - Masked Input Widget
<input ng-model="contact.phone" ui-mask='"(9999) 9999 9999"' placeholder="(01234)-5678-8901" required />
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: 'response.data.response.data'});
@petebacondarwin
petebacondarwin / app.coffee
Created March 13, 2012 21:09
Handlers in Angular Routes
angular.module('AppConfig',[])
.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
###
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
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'