This is a list of materials I've compiled that can give you the best possible start at understanding all the things that you'll need to get up and running building web applications with Angular JS using the awesome workflow tools in Lineman JS :)
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
def 'mixins.addPresetAwarenessTo', (presetAwareModel, modelClassesToAddAwarenessTo) -> | |
_.each modelClassesToAddAwarenessTo, (modelClass) -> | |
modelClass::getPresets = -> null | |
presetAwareModel.on "change:presets", (m, presets) -> | |
modelClass::getPresets = -> | |
presets |
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
# this is a mixin from backbone app that allows callbacks and conventions around attaching them to | |
# views to work in a couple different ways. | |
# the specfile included here reveals the intent of how the mixin should be used | |
def 'mixins.addCallbackConventionTo', (target, receiver) -> | |
ensureBackboneEventsHaveBeenAddedTo(target) | |
mixins.mix target, with: | |
callbackNameFor: (name) -> 'on'+_(name).titleize() | |
callback: (name, stuff...) -> |
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("app", ["some", "other"]); | |
angular.module("some", []).factory('greet', function(name) { // note the 'name' injection here... | |
return function() { // instead of here | |
return 'Hi ' + name + '!'; | |
}; | |
}); | |
angular.module("other", []).value('name', 'example'); |
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
{ | |
"version": 3, | |
"file": "app.js", | |
"sources": [ | |
"vendor/js/angular.js", | |
"vendor/js/angular-resource.js", | |
"vendor/js/underscore.js", | |
"generated/js/app.coffee.js", | |
"app/js/app.coffee", | |
"generated/js/authentication_service.coffee.js", |
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() { | |
var $injector = angular.injector(['ng']); | |
$injector.invoke(function($http) { | |
// this works! | |
$http.get("/auth/csrf_token").then(function(response) { | |
angular.module("app").constant("CSRF_TOKEN", response.csrf_token); | |
angular.bootstrap(document, ['app']); | |
}); |
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
// https://github.com/jehna/VerbalExpressions | |
var VerEx = require("verbal-expressions"); | |
var isValidPhone = | |
VerEx() | |
.startOfLine() | |
.maybe( | |
VerEx().range("1", "9").add("{1}").then("-")) | |
.then( | |
VerEx().add("(?!800|900|976|877|866)").range("0", "9").add("{3}").then("-")) |
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
listenToAjaxEvents: function() { | |
var _this = this; | |
_($(document)).tap(function(doc) { | |
doc.on("ajaxStart", _this.loading_indicator.show); | |
doc.on("ajaxError", _this.loading_indicator.hide); | |
doc.on("ajaxError", _this.redirectOnError); | |
doc.on("ajaxStop", _this.loading_indicator.hide); | |
}); | |
} |
The pre-commit file listed here is setup to scan files for invalid keywords prior to commit to avoid debug or logging information making its way into production files. Right now it is setup to scan only .js
and .coffee
files for the following keywords:
KEYWORDS_REGEX="console\.(debug|info|log|warn)\(|alert\(|debugger"
EXTENSIONS_REGEX="(.js$|.coffee$)"
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("app").factory('AuthenticationService', function($http) { | |
return { | |
login: function(credentials) { | |
return $http.post('/login', credentials); | |
}, | |
logout: function() { | |
return $http.post('/logout'); | |
} | |
}; | |
}); |