Asynchronous JavaScript – AJAX

Reference:  https://developer.mozilla.org/en-US/docs/AJAX/Getting_Started, http://www.cnblogs.com/mingmingruyuedlut/archive/2011/10/18/2216553.html AJAX stands for Asynchronous JavaScript and XML. It is the use of the XMLHttpRequest object to communicate with server-side scripts. It can send as well as receive information in a variety of formats, including JSON, XML, HTML, and even text files. AJAX’s most appealing characteristic, however, is its “asynchronous” nature, which means …

Read More

Asynchronous JavaScript – Callbacks & Event Listeners

Reference: http://www.ruanyifeng.com/blog/2012/12/asynchronous%EF%BC%BFjavascript.html, http://sporto.github.io/blog/2012/12/09/callbacks-listeners-promises/, https://www.sitepoint.com/javascript-goes-asynchronous-awesome/ As mentioned in the previous post, there are many tools you can use to deal with asynchronous development in JavaScript. So Here we will discuss Callbacks and Event Listeners. Callbacks Let’s start with callback pattern, this is the most basic and the best known pattern to deal with async programming. A callback looks like this: finder([1, …

Read More

Asynchronous JavaScript – Overview

Reference: http://www.ruanyifeng.com/blog/2012/12/asynchronous%EF%BC%BFjavascript.html As is known to all, the environment of JavaScript runtime is ‘single thread’, which means the JS engine can only handle one task at one time. If there exists several tasks, the tasks should wait in a queue. Only the former task has finished, the latter one can be executed. The tasks are executed one …

Read More

Sharing Data Between Controllers in AngularJS

Reference: http://stackoverflow.com/questions/21919962/share-data-between-angularjs-controllers Sharing data between controllers is quite common when using AngularJS. There are many ways that can make it: Scope inheritance Using services Using event Scope inheritance Scope inheritance has been mentioned in Passing Data Between Parent/Child Scopes in AngularJS. You can only share data between parent and child controllers by this way. Here is a simple example: In Html: …

Read More

Understanding Scopes in AngularJS

Reference: https://github.com/angular/angular.js/wiki/Understanding-Scopes In AngularJS, a child scope normally prototypically inherits from its parent scope. One exception to this rule is a directive that uses scope: { … } — this creates an “isolate” scope that does not prototypically inherit.(and directive with transclusion) This construct is often used when creating a “reusable component” directive.  Scope inheritance is normally …

Read More