Passing Data Between Parent/Child Scopes in AngularJS

Reference: http://stackoverflow.com/questions/14049480/what-are-the-nuances-of-scope-prototypal-prototypical-inheritance-in-angularjs 1. The problem Scope in AngularJS is a bit tricky. When we are using nested controller in AngularJS, since each controller has its own scope,  the nesting of controller means the nesting of scope. If there are two models with the same name both in the parent and child scope, what will happen? Can we …

Read More

Scope in JavaScript

Reference: Pro JavaScript Techniques: Second Edition By John Paxton, John Resig, Russ Ferguson Scope is a tricky feature of JavaScript. Most programming languages have some forms of scope; the differences lie in the duration of that scope. There are only two scopes in JavaScript: functional scope and global scope. Functions have their own scope, but blocks (such as while, if, …

Read More

The Module Pattern in JavaScript

Reference: Pro JavaScript Techniques: Second Edition By John Paxton, John Resig, Russ Ferguson The module pattern is probably the one most commonly used by JavaScript developers. It encapsulates generation of the namespace within a function. Here is a very simple example of the module pattern: function getModule() { // Namespaces example var FOO = {}; // Add a …

Read More

Closures in Javascript

Reference: https://developer.mozilla.org/en/docs/Web/JavaScript/Closures Closures are functions that refer to independent (free) variables (variables that are used locally, but defined in an enclosing scope). In other words, these functions ‘remember’ the environment in which they were created. It’s quite tricky when I start to study JavaScript. There is no similar concept in C#, so I can not transfer the idea. That is one of …

Read More

The CASE statement in SQL

Here is the situation I meet nowadays: This is a very simple database, only including three tables: The students table is the main table. And if a student is a good student, there will be records in StudentsGoods table. Similarly, if a student is a bad student, there will be records in StudentsBads table. I want …

Read More

A SQL exercise

Here is a simple exercise of SQL on SQLZOO.  The table is like this: name continent area population gdp Afghanistan Asia 652230 25500100 20343000000 Albania Europe 28748 2831741 12960000000 Algeria Africa 2381741 37100000 188681000000 Andorra Europe 468 78115 3712000000 Angola Africa 1246700 20609294 100990000000 … The tenth question: Some countries have populations more than three …

Read More