Over a million developers have joined DZone.

The Unstable Future of Angular.js

· Java Zone

Discover how powerful static code analysis and ergonomic design make development not only productive but also an enjoyable experience, brought to you in partnership with JetBrains

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:

The reason that it breaks minification, is that is using some really clever trickery to abuse parts of the javascript language, to do things that conflict with the fundamentals of the language itself.

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.

The developers of Angular.js agree that this "black magic" is a problem, and have said that the issue will be fixed in the upcoming Angular.js 2.0.

Learn more about Kotlin, a new programming language designed to solve problems that software developers face every day brought to you in partnership with JetBrains.


The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}