Skip to content

Instantly share code, notes, and snippets.

View richardm's full-sized avatar

Richard Morgan richardm

View GitHub Profile
@richardm
richardm / api.js
Created February 26, 2014 20:23
Using $httpBackend to develop an AngularJS frontend using test data before the backend is ready. Be sure to include jSendHttp, angular-sanitize.js, and angular-mocks.js.
angular
.module('API', ['testData']) // Remove testData to make real http request
.factory('UsersAPI', function ($http, $q, $jSendHttp) {
return {
getUsers: function (companyId) {
return $jSendHttp.get('/api/UsersController/getUsers?companyId=' + companyId);
}
};
});
@richardm
richardm / Backbone.js - Global Namespaced Events.js
Last active December 18, 2015 09:29
Extending Backbone Views to add global namespaced events
// Basic App Setup
var App = window.App = {
Models: {},
Views: {},
Collections: {},
View: {} // set below
};
// Custom App View with global namespaced events