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() { | |
'use strict'; | |
var express = require('express'); | |
var app = express(); | |
app.use(express.static('public')); | |
app.use("/", express.static(__dirname)); | |
app.listen(3033); |
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
var app = angular.module('myApp',[]). | |
directive('communicator', function(){ | |
return { | |
restrict : 'E', | |
scope:{}, | |
controller : "@", | |
name:"controllerName", | |
template:"<input type='text' ng-model='message'/><input type='button' value='Send Message' ng-click='sendMsg()'><br/>" | |
} | |
}). |
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
//Using $$ | |
[].forEach.call($$("*"),function(a){ | |
a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16) | |
}) | |
//Using document.querySelectorAll: | |
[].forEach.call(document.querySelectorAll("*"),function(a){a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16)}) |
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
var myapp = angular.module('myApp', []) | |
// allow DI for use in controllers, unit tests | |
.constant('_', window._) | |
// use in views, ng-repeat="x in _.range(3)" | |
.run(function($rootScope) { | |
$rootScope._ = window._; | |
}); |
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
Usage : | |
var collections = [ | |
{id: 1, name: 'xyz'}, | |
{id: 2, name: 'ds'}, | |
{id: 3, name: 'rtrt'}, | |
{id: 4, name: 'nhf'}, | |
{id: 5, name: 'qwe'} | |
]; | |
var filtered = _.findByValues(collections, "id", [1,3,4]); |
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
// Domain Object Model | |
// Mapping service JSON value to Value object. | |
// Use Constructor Functions | |
// Use prototype methods | |
// Use static methods | |
// Do response mapping | |
function User(id, fname, lname) { |
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 () { | |
'use strict'; | |
angular.module('myApp', []) | |
.filter('moment', [ | |
function () { | |
return function (date, method) { | |
var momented = moment(date); | |
return momented[method].apply(momented, Array.prototype.slice.call(arguments, 2)); | |
}; |
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
app.directive('clickOutSide', function($document){ | |
return { | |
restrict: 'A', | |
link: function(scope, elem, attr, ctrl) { | |
elem.bind('click', function(e) { | |
// this part keeps it from firing the click on the document. | |
e.stopPropagation(); | |
}); | |
$document.bind('click', function() { | |
// magic here. |
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
app.directive('ngEnter', function () { | |
return function (scope, element, attrs) { | |
element.bind("keydown keypress", function (event) { | |
if(event.which === 13) { | |
scope.$apply(function (){ | |
scope.$eval(attrs.ngEnter); | |
}); | |
event.preventDefault(); | |
} |
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
var app = angular.module('myApp', | |
['myApp.services', 'myApp.controllers']); | |
app.run(['$rootScope', function($root) { | |
$root.$on('$routeChangeStart', function(e, curr, prev) { | |
if (curr.$$route && curr.$$route.resolve) { | |
// Show a loading message until promises aren't resolved | |
$root.loadingView = true; | |
} | |
}); |
OlderNewer