sessionStorage/localStorage scope

Firstly, localStorage and sessionStorage are 2 objects on the window object. They tie to the origin of the current window. As a result they are bind to : protocol, http/https are different domain subdomain can share with parent by manually setting document.domain. xxx.capitalone.com cannot share with yyy.capitalone.com port Same thing apply to 302 redirect. The session/local storage value…

ng-show ng-if not just in DOM or not

I was thinking I had enough knowledge about the different about ng-if and ng-show which are one adds/removes the containing stuff from the DOM and the latter one just use CSS to hide/show. What’s ironic is I even sometimes use this as an interview question. Today I was bitten by it. According to the Angualrjs Doc:…

angularjs $scope form undefined

Was developing some form with angular, things work perfect until I add a angular-ui bootstrap tab to enclose 2 different form in each tab. when i try to access the form with $scope.formName, the formName is undefined. It turns out that the angularUI tab directive uses transclude which will create a child scope to the…

Javascript 严格模式详解 use strict

全局变量显式声明(must use var) 在正常模式中,如果一个变量没有声明就赋值,默认是全局变量。严格模式禁止这种用法,全局变量必须显式声明。 “use strict”; v = 1; // 报错,v未声明 for(i = 0; i < 2; i++) { // 报错,i未声明 } 因此,严格模式下,变量都必须先用var命令声明,然后再使用。 重名错误(No duplicate var/function name) 严格模式新增了一些语法错误。 (1)对象不能有重名的属性 正常模式下,如果对象有多个重名属性,最后赋值的那个属性会覆盖前面的值。严格模式下,这属于语法错误。   ”use strict”; var o = { p: 1, p: 2 }; // 语法错误 (2)函数不能有重名的参数 正常模式下,如果函数有多个重名的参数,可以用arguments[i]读取。严格模式下,这属于语法错误。   ”use strict”; function f(a, a, b) { // 语法错误 return…

inspect angularjs scope controller in chrome(webkit)

Pick an element in the HTML panel of the developer tools and type this in the console angular.element($0).scope() In webkit $0 is a reference to the selected DOM node in the elements tab, so by doing this you get the selected DOM node scope printed out in the console Also you could assign this to…

angularjs scope inheritence primitive object

JavaScript Prototypal Inheritance It is important to first have a solid understanding of JavaScript prototypal inheritance, especially if you are coming from a server-side background and you are more familiar with classical inheritance. So let’s review that first. Suppose parentScope has properties aString, aNumber, anArray, anObject, and aFunction. If childScope prototypically inherits from parentScope, we…

Angular’s $scope event system $emit, $broadcast and $on

Angular’s $emit, $broadcast and $on fall under the common “publish/subscribe” design pattern, or can do, in which you’d publish an event and subscribe/unsubscribe to it somewhere else. The Angular event system is brilliant, it makes things flawless and easy to do (as you’d expect!) but the concept behind it isn’t so simple to master and…

javascrip closure

First, a very very good article explaining CLOSURE Second, I like this answer in Stackoverflow: A function in JavaScript is not just a reference to a set of instructions (as in C language) but also includes a hidden data structure which is composed of references to all nonlocal variables it uses (captured variables). Such two-piece…