Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am alatzl on github.
  • I am aatzl (https://keybase.io/aatzl) on keybase.
  • I have a public key ASDP5Aana-GMM26wQUOxcaV4XNBBrN-SzHVI5DMVFN1PTQo

To claim this, I am signing this object:

@alatzl
alatzl / _.md
Created June 23, 2015 16:30
Three Circles Setup
@alatzl
alatzl / _.md
Created June 23, 2015 16:29
Gradient Bars Setup
@alatzl
alatzl / _.md
Last active August 29, 2015 14:23
Three Circles Setup
@alatzl
alatzl / adoptingAngular_example5.js
Created May 12, 2015 18:11
Create a base service and extend for each specific use case.
// Base service
angular.module('petStoreApp', [])
.service('petService', function($http) {
var petSvc = function(_endpoint_) {
var endpoint = _endpoint_ + '/';
return {
getList: getList,
getInfo: getInfo
};
@alatzl
alatzl / adoptingAngular_example4.js
Created May 12, 2015 17:59
Two services that do almost the same thing; we can abstract out the repetition.
// An example showing two services that are nearly identical
angular.module('petStoreApp', [])
.service('catService', function($http) {
var svc = {
getList: function() { // get a list of all cats
$http({ method: 'GET', url: 'cats/all' })
.then(successFn, errorFn);
},
getInfo: function(catId) { // get info about a specific cat
$http({ method: 'GET', url: 'cats/' + catId })
@alatzl
alatzl / adoptingAngular_example3.js
Created May 12, 2015 17:31
Use Angular.constant() and Angular.value()
// Instead of this:
angular.module('petStoreApp', [])
.controller('petStoreOneCtrl', function($scope) {
$scope.myCat = {
name: 'Grumpy',
type: 'cat'
};
$scope.myDog = {
name: 'Lassie',
type: 'dog'
@alatzl
alatzl / adoptingAngular_example2.js
Created May 11, 2015 18:06
Utilize Angular's built-in services
// Instead of using $.ajax for an API call...
angular.module('app', [])
.factory('addressBook', function() {
var data = null;
return {
getAddresses: function() {
$.ajax({
url: '/path/to/data',
dataType: 'json',
@alatzl
alatzl / adoptingAngular_example1.js
Created May 11, 2015 16:20
Wrap Global Variables in Services
// Instead of this:
angular.module('app', [])
.controller('MyCtrl', function($scope) {
// What is moment? How do I know this exists and is the right object?
$scope.startTime = moment();
$scope.endTime - moment().add(1, 'h');
});
// Try this:
angular.module('app', [])
@alatzl
alatzl / DirectiveExample2.js
Last active August 29, 2015 14:19
Writing Angular with Migration in Mind: Ex. 4
angular.module('myModule')
.directive('roar', function() {
return {
restrict: 'E',
scope: {},
controller: roarCtrl,
controllerAs: dinoRoar,
bindToController: {
dinoType: '@'
}