A simple example of how to use angular's $interval service. This service is an nice evolution of the window.setInterval/clearInterval methods. Here's my blog on this: http://dankahle.blogspot.com/2014/08/angulars-interval-service.html
var users = [ | |
{id:'dk', name: 'dank', age:50}, | |
{id:'cy', name: 'carl', age:60}, | |
{id:'js', name: 'jim', age:40} | |
]; | |
if(!window && typeof module != 'undefined'){ | |
module.exports.friends = friends; | |
module.exports.users = users; | |
} |
Forms can be quite tedious in angular, mostly having to do with messages. There's several options: highight the invalid fields or show messages, show messages only when dirty, disable submit button, etc. I don't like the disabled submit button as it leaves the user guessing which field is invalid, and... if they're not guessing which field is invalid, then all invalid fields or messages are "always" shown, I don't care for that as well. My solution this time around was to show messages only when dirty, leaving the submit button enabled, then setting all fields to dirty upon submission. So, no messages shown until the submit button is hit or they visit the field Upon submit all messages are shown for invalid fields. This feels right.
Also, played around a bit with ng-module-options.updateOn and have to say, blur isn't cool. You just can't wait for a blur event for error message updates or even field updates (a select won't change it's value after you select an o
var mongodb = require('mongodb'), | |
MongoClient = mongodb.MongoClient, | |
Q = require('q'), | |
def = Q.defer(), | |
db, | |
initialized | |
module.exports = function(init) { |
var fs = require("fs"); | |
function main() { | |
fs.readdir("./node_modules", function (err, dirs) { | |
if (err) { | |
console.log(err); | |
return; | |
} | |
dirs.forEach(function(dir){ | |
if (dir.indexOf(".") !== 0) { |