This file contains 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('com.servicelayer', []) | |
.constant("ServicesLocator", | |
{ | |
// *** dev *** | |
DOMAIN: "https://", | |
SOME_SERVICE: "someservice", | |
ANOTHER_SERVICE: "another/service", | |
// *** dev *** |
This file contains 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('interceptor', | |
["com.servicelayer"], | |
function($q, ErrorService) | |
{ | |
return { | |
response: function (response) { | |
// do something on success | |
if(response.headers()['content-type'] === "application/json; charset=utf-8"){ | |
//TODO: check for error codes and delegate to error handler service |
This file contains 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
factory('ErrorService', | |
function($injector, $window, ServicesLocator, StacktraceService, Debounce, Logger) | |
{ | |
var $http = null; | |
var ErrorService = { | |
log: function(exception, cause) | |
{ | |
if($http == null) | |
{ |
This file contains 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('com.servicelayer.errors', | |
['ngResource', 'logging']) | |
.config(['$provide', function($provide) | |
{ | |
$provide.decorator('$exceptionHandler', function($delegate, ErrorService) | |
{ | |
return function(exception, cause) | |
{ | |
$delegate(exception, cause); | |
ErrorService.log(exception, cause); |
This file contains 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
// assuming user JSON object comes back with role; I don't care if y'all encrypt/hash it | |
$scope.user = null; | |
$http.post("some/auth", {credentials}) | |
.success(function(data, status, headers, config) | |
{ | |
/* | |
// JSON looks like | |
{ | |
data: { | |
user: { |
This file contains 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
karma: { | |
options: { | |
configFile: 'karma.configuration.js' | |
}, | |
unit: { | |
runnerPort: 9101, | |
background: true, | |
port: 9877 | |
}, | |
continuous: { |
This file contains 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
<html> | |
<head><title>Angular Basics</title></head> | |
<script src="angular.js"></script> | |
<body ng-app="app"> | |
<script> | |
function shouldEqual(a, b) |
This file contains 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
/* jshint -W117, -W030 */ | |
(function() { | |
'use strict'; | |
describe('simple directive test:', function() { | |
describe('factory', function() { | |
var scope; | |
beforeEach(function() { | |
module('wdpr.angular-validators'); | |
}); |
This file contains 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
// uses mocha and chai | |
it('basic lodash _.every function is strange', function() { | |
_.every([true]).should.be.true; | |
_.every([true], true).should.be.false; | |
_.every([true, true], true).should.be.false; | |
_.every([true, true, true], true).should.be.false; | |
_.every([false, false, false], Boolean).should.be.false; | |
_.every([false, false, false], false).should.be.false; | |
}); |
This file contains 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 getPlayer() | |
{ | |
return { | |
isWorthy: true | |
} | |
} | |
function determineIfWorthy(player) | |
{ | |
return player.isWorthy(); |