This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const defaultMenu = ['hamburger', 'french fries', 'soda']; | |
| const guestNames = ['John', 'Jane', 'Bill']; | |
| const guest = (name) => ({ | |
| name, | |
| foods : defaultMenu, | |
| eat(food) { | |
| this.foods.push(food); | |
| return this; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const _addToGroup = (keyFn) => (result, item) => | |
| (result[keyFn(item)] = result[keyFn(item)] || []).push(item) && result; | |
| const groupBy = (array, keyFn) => array.reduce(_addToGroup(keyFn), {}); | |
| let objects = [ | |
| { id: 0, name: 'root', parent: null }, | |
| { id: 1, name: 'foo', parent: 0 }, | |
| { id: 2, name: 'bar', parent: 1 }, | |
| { id: 3, name: 'baz', parent: 1 }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* @ngInject */ | |
| export default function wsResource(wsEndpoints, resource) { | |
| /* eslint-disable no-confusing-arrow */ | |
| const mapRecursively = obj => | |
| Object.assign(...Object.keys(obj) | |
| .map(key => (obj[key] && typeof obj[key] === 'object') ? | |
| { [key]: mapRecursively(obj[key]) } : | |
| { [key]: resource.create(obj[key]) } | |
| ) | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('app').factory('myService', function($q, $http){ | |
| var data; | |
| var dataPromise; | |
| return { | |
| getData: getData | |
| } | |
| function getData(){ | |
| //If the data is already here, return it in a resolved promise |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular | |
| .module('smartjs').directive('onlyForAdmin', function(ngIfDirective) { | |
| ngIfDirective = ngIfDirective[0]; | |
| return { | |
| transclude: ngIfDirective.transclude, | |
| priority: ngIfDirective.priority, | |
| terminal: ngIfDirective.terminal, | |
| restrict: ngIfDirective.restrict, | |
| link: function($scope, $element, $attr) { | |
| $attr.ngIf = 'user.isAdmin'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** API Abstraction Layer used to simplify resource loading and pagination | |
| * | |
| * | |
| */ | |
| angular.module( 'laundureeApp' ) | |
| .provider( 'api', [ function(){ | |
| var api = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ngAnimate helper mixins | |
| // first it helps to have a single transition for everything. you can always fine-tune later: | |
| $base-transition: 0.5s ease all | |
| // this set of mixins which works for both ng-if and and ng-show: | |
| @mixin revealTo($transition: $base-transition) | |
| @content |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| usage: | |
| Initializer.mapsInitialized.then(function(){ | |
| initMap(); // do stuff with maps | |
| }); | |
| */ | |
| angular.module('ngApp', []). | |
| factory('Initializer', function($window,$q){ | |
| var asyncUrl = '//maps.googleapis.com/maps/api/js?callback=', | |
| mapsDefer = $q.defer(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function _getApiToAuthorize(apiUrl) { | |
| return _.reduce(apiUrl, function fn(result, url, key) { | |
| if (typeof url === 'object') { | |
| _.reduce(url, fn, result); | |
| } else { | |
| if (key === 'tokens') { | |
| return result; | |
| } | |
| result.push(url); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('OrderApp', function() { | |
| describe('Service: MenuResult', function() { | |
| beforeEach(module('OrderApp')); | |
| beforeEach(inject(function($httpBackend) { | |
| mock_response = { | |
| results: [{ | |
| _id: "1234567890", | |
| url: "/food/pizza", | |
| title: 'Pizza' |