Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

The Unstable Future of Angular.js

DZone's Guide to

The Unstable Future of Angular.js

· Java Zone
Free Resource

Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat.

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.

Download Modern Java EE Design Patterns: Building Scalable Architecture for Sustainable Enterprise Development.  Brought to you in partnership with Red Hat

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

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

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}