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
| for (var i = 0; i < 5; i++) { | |
| setTimeout(function() { | |
| console.log(i); | |
| }, 1000); | |
| } | |
| // How do we fix the above to log what we want it to log? | |
| for (var j = 0; j < 5; j++) { | |
| // With an IIFE (immediately-invoked function expression) | |
| // Closures |
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 bind(expr, data, el){ | |
| el.render = render.bind(null, expr, data, el); | |
| return on('squirt.els.render', function(){ | |
| el.render(); | |
| }); | |
| }; | |
| function render(expr, data, el){ | |
| var match, rendered = expr; | |
| expr.match(/{{[^}]+}}/g).map(function(match){ |
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
| <!DOCTYPE html> | |
| <html> | |
| <head lang="en"> | |
| <meta charset="utf-8"> | |
| <title>Directives Talking to Controllers</title> | |
| </head> | |
| <div ng-app="twitterApp"> | |
| <div ng-controller="AppController"> |
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
| <!DOCTYPE html> | |
| <html> | |
| <head lang="en"> | |
| <meta charset="utf-8"> | |
| <title>Isolate Scope @</title> | |
| <style type="text/css"> | |
| .inline { | |
| display: inline-block; | |
| } | |
| </style> |
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
| // in AngularJS (client) | |
| myApp.config(['$httpProvider', function($httpProvider) { | |
| $httpProvider.defaults.useXDomain = true; | |
| delete $httpProvider.defaults.headers.common['X-Requested-With']; | |
| }]); | |
| // in NodeJS/Express (server) | |
| app.all('/*', function(req, res, next) { | |
| res.header("Access-Control-Allow-Origin", "*"); | |
| res.header("Access-Control-Allow-Headers", "X-Requested-With"); |
NewerOlder