AngularJS, JavaScript

All Angular Directives That Create Child Scopes

Have this list firmly registered somewhere in the back of your head before embarking on Angular! I can’t tell you how much confusion and pain not realising its existence has caused me. These are the keywords I used to find all the directives that create scope, thanks to @sp00m’s prompt.

Providing that Angular’s documentation is consistent in the way they describe directives, which it seems to be, below is the full list of results, in order of priority level of execution:

  1. 1200, ngSwitch
  2. 1000, ngRepeat
  3. 600, ngIf
  4. 500, ngController
  5. 400, ngInclude
  6. 400, ngView
  7. 0, ngMessage
Standard
JavaScript

jQuery Plugin: jquery-transformer

Since I constantly need to use jQuery together with TweenMax and since TweenMax already took care of all the parsing of various types of transformation strings as well as compatibility issues, I wrote a tiny jquery plugin here (more of a wrap up of gsap’s) that could directly access these values like this:

$('#ele').transform('rotationX') // returns 0
$('#ele').transform('x')         // returns value of translate-x

Continue reading

Standard
JavaScript

Tongue Twisting This

Inside a function A, THIS always points to the scope outside the function A. Unless, it gets NEWed. Then THIS would point to the object NEWed out, all the THISes inside of that function A,  inside of the function B that’s inside of the function A, and inside of the function C that’s inside of the function B that’s inside of the function A… Since the this inside of function A is the object, and all the functions inside of function A points to their outer scope, which is the THIS inside of function A.

Continue reading

Standard