The Unstable Future of Angular.js
Join the DZone community and get the full member experience.Join For Free
Google's overwhelmingly successful dynamic HTML enhancement, Angular.js, has a flaw that could limit the platform's longevity. While there is nothing inherently wrong about Dependency Injection systems, Adrian Rossouw's recent post explains how some instructions given in the developer's manual cause minification to break down when encountering certain functions. Rossouw states:
Specifically, it uses Function.prototype.toString(), to read the source code of the function that is being called, and extract the names that the parameters were given in your source. Because minification changes those variable names, it can no longer rely on that to work.
The following video illustrates exactly how Angular.js breaks in this situation:
It is odd that such a bizarre occurrence exists in an otherwise beautifully constructed platform. Even more baffling is the fact that this option is first in a list of three ways to accomplish the exact same task, and the other two options are perfectly fine. Rossouw provides a colorful explanation of this issue:
On your first day at a new company, you are offered the use of one of three company cars.
As you slip into the red car nearest you, you notice a small sign on the dashboard saying “warning: red cars will explode violently on wednesdays”.
I worry about the fact that something like this is just accepted and people have decided that it’s easier to just warn others about the exploding cars rather than just not giving people exploding cars to begin with. This is expounded by the fact that there are two other perfectly working cars, which might not be your favorite color, but at least they won’t kill you.
Opinions expressed by DZone contributors are their own.