
Angular 1 and Angular 2 integration: the path to seamless upgrade - hswolff
http://angularjs.blogspot.com/2015/08/angular-1-and-angular-2-coexistence.html
======
escobar
I have been evaluating writing some new applications in Angular at work and
was quickly turned away from it because before today the actual migration path
seemed very unclear. Without a migration path, picking v1 for a new
application at this point would be silly, and 2 is completely unready for
production.

Hearing that they are really planning on making it more or less "backwards
compatible" is definitely a smart move from the Angular team, and makes me
more comfortable potentially suggesting Angular as a framework.

~~~
fougerejo
Since Angular 2 was announced, I had the feeling that I picked the wrong
framework for our product with Angular 1, and was feeling regrets about that
choice towards my team, to have blocked them with a framework without future.

Knowing that we'll be able to slowly move our app to Angular 2, one feature at
a time, is certainly the best news I've had in a while.

~~~
fougerejo
BTW, why do I always feel like betting in a horse race when choosing a web
framework/library? Hoping it'll be maintained long enough, hoping it'll not be
deprecated after 6 months for the new cool kid...

~~~
k__
I had always a bad feeling about angular.

The first guy I heard talking about it was like "It was made by an underdog at
google" and "We often had the feeling about hitting a dead end when developing
with it, but it was always because we were using it wrong" which both sounded
strange to me.

I used ExtJS, Ember and React. And never switched away from them because it
wasn't maintained anymore. It just happened that people preferred to use new
frameworks on new projects.

~~~
jsprogrammer
ExtJS went through some rough upgrade cycles as well. From what I remember,
the 2->3 upgrade path covered a small subset of codebases.

~~~
d215
Ember OTH has the smoothest upgrade path known to man.

~~~
Bahamut
Not that smooth if you saw the comments on HN last week - teams lost months of
productivity keeping up with the rewrites in Ember, even with no immediate
breaking changes.

~~~
nstart
Can I have a link to that please?

~~~
Bahamut
[https://news.ycombinator.com/item?id=10054717](https://news.ycombinator.com/item?id=10054717)

------
tericho
Seeing a lot of comments about how Angular had no migration plan. Migration
was discussed at length at ng-conf back in March, including a large portion of
the keynote(s). They made it very clear a smooth and simple migration was top
priority.

Part of migration talk in keynote:
[https://youtu.be/QHulaj5ZxbI?t=12m43s](https://youtu.be/QHulaj5ZxbI?t=12m43s)

Full playlist:
[https://youtu.be/QHulaj5ZxbI?list=PLOETEcp3DkCoNnlhE-7fovYvq...](https://youtu.be/QHulaj5ZxbI?list=PLOETEcp3DkCoNnlhE-7fovYvqwVPrRiY7)

~~~
kylecordes
Yes, it is a considerable frustration. At the beginning, the Angular team said
something along the lines of "we are working on a Angular 2, after we figure
out how it should work then we will consider migration and come up with a
plan". For some reason this was widely interpreted as "there will be no
migration plan".

~~~
jbergens
I agree that there were a lot of misunderstanding going around but it has
caused some problems. For new projects you have to choose a
platform/framework. If you choose Angular 1 you might have to learn it and
release a version of your app with it before Angular 2 is released or just
before the migration path is clear. And it is till hard to estimate the
migration cost/time. Or you could start with Angular 2 which you knew was not
ready. It was and is also unclear exactly when Angular 2 will be "ready"
making it a less interesting choice if you have/had a hard date when your app
should be released.

------
Goranek
I know that hating angular is popular these days, but i'm still using it, and
it serves me well. Looking forward to Angular 2!

~~~
NicoJuicy
Yeah, it seemed that way because there was no migration path... That is fixed
though ;)

Almost everyone i know is using something in the likes of AngularJS

~~~
jbergens
> Almost everyone i know is using something in the likes of AngularJS I do
> wonder what you mean with that. I think that both React and Ember are
> different but if you mean a javascript framework for building single page
> applications you're probably right.

~~~
NicoJuicy
Everyone who is following a bit of technology and/or searching for extra
developers ( Brussels/Belgium) are all using AngularJS. Haven't found any
mention of EmberJS or React or anything ( doesn't mean they don't know it)

There was only one difference, someone used AngularJS with Typescript :) ==>
c#

------
pfooti
This looks nice. I like the idea of more-or-less seamless integration between
a1 and a2 on the same page, to allow for incrementally experimenting with a2
features without having to port the entire application over.

With angular 2 moving to a virtualdom implementation we can get serverside
rendering and some real speed improvements (if you move your virtualdom stuff
to a web worker for example). This is rad.

------
omouse
Every time I use Angular it feels like it's doing things the right way and
it's becoming the Rails or Django of the JavaScript world. Wish I had fought
to use AngularJs directives and $resource instead of messing about with
ReactJS and jQuery ajax calls.

With this migration plan it seems silly _not_ to keep hacking with AngularJS
1.x

~~~
jbergens
If you're using React you could look into different flux frameworks or even
Relay+GraphQL to avoid jQuery ajax (or at least hide it). That last thing is
the bleeding edge right now but looks promising. Flux is probably here to stay
and you have a ton of libraries to choose from. I started with Reflux but is
now using Alt.

~~~
Bahamut
GraphQL requires backend infrastructure to use, which takes time usually to
plug into the planning pipeline.

------
gedy
I see 2-way data-binding is mentioned here and will still be supported (good).
Curious why has 2-way now become 'uncool' recently, e.g. React? 2-way is what
got me excited about client side JS due to the code reduction in an average
app. Is just that Angular 1's implementation was non-performant? (lots of
other frameworks use it as well, e.g. Knockout, RactiveJS, etc).

~~~
pfooti
Two way data binding is awesome and neat and shiny and chrome. It's also
pretty slow; a lot of pragmatic angular work involves keeping the number of
watchers firing during digest cycles minimized. If you have a lot of data
that's all two-way-bound by default, but aren't making any use of the
bindings, that's a lot of wasted cycles. I mean, my app has a lot of data in
it, stuff like {{username}} which rarely ever changes in the model, so I don't
really need two-way binding for it.

What I like here is that one-way binding is the default, and you can do two-
way stuff if needs be, because sometimes it really is the best call.

~~~
lemevi
I think two-way binding going by the way side because developers are tired of
having to deal with unintended loop backs. You start having to add weird flags
to your data to indicate that data changes were the result of user actions and
not changes from the backend to avoid endless event loops. Two-way binding
results in more code that's buggier whereas one-way binding with actions
results in much more organized and understandable code with none of the
unintended consequences.

~~~
gedy
I'm thinking that's a framework-specific or coding-style issue? From using a
number of frameworks, I've virtually never had issues with endless loops.
Perhaps it helps that frameworks like Knockout, etc don't trigger change
events when the value is the same.

------
netfire
Why isn't there a single domain for the angular project?

From what I can see there seems to be 2 main ones: angular.io (for angular 2)
and angularjs.org (for angular 1.x) as well as angulardart.org and other sites
for angular material design (material.angularjs.org) and angular firebase
(firebase.com/docs/web/libraries/angular/). Why not have a single site (or at
least a main domain with corresponding subdomains) with similar documentation
and navigation?

In addition, searching for "angular" in Google provides no obvious distinction
between the different sites. For a Google sponsored project, I would have
expected better attention to the search meta-data to make the distinction
clear.

~~~
eridal
> In addition, searching for "angular" in Google provides no obvious
> distinction between the different sites.

You can try to search using DuckDuckGo as it highlights _official sites_.
Really useful feature, even for quick one-time searches.

[https://duckduckgo.com](https://duckduckgo.com)

~~~
netfire
Aren't they both official sites though, just of their respective versions?
(although admittedly, Angular 2 is still in the Developer Preview stage)

------
aikah
See , that's how you manage an open source project , you listen to your
community , and yes people can have relevant suggestions. Angular JS became
successful because of its pragmatism but also because it allowed more than
1000 people to contribute to its core, not because it was a "Google project" .

Everybody knows what other project i'm talking about.

~~~
us7892
What other project are you talking about?

~~~
billturner
If they mean closed source, that list could include Google +, Google Reader,
Google Wave, etc

------
weego
<input type="text" [(ng-model)]="model.name">

Remember when we were worried about the semantic purity of our HTML.

~~~
mariusmg
Remember separation of concerns ? Fuck that, let's just mash code and markup
together.

~~~
pluma
The fun part is that Angular (1, anyway) has pretend-separation. Sure, there's
truth in DOM, but not really. Littering your custom directives all over the
place may feel like progressive enhancement but if you're using an app
framework like Angular your JS is likely already complex enough that you can't
meaningfully consider it a mere "enhancement" \-- we're talking core
functionality, not fairy dust.

People react (heh) strongly to React's JSX when they first come across it but
at the end of the day I find React far more honest in its approach. Your
Angular templates don't really gain anything from looking like they're just
HTML templates -- instead you end up either serializing your data into some
kind of string format or faffing about with magical nested "scope" objects (as
if JS scoping wasn't enough to keep in your head).

But in order to maintain that illusion you also have to buy into these huge
layers of added complexity when writing your own directives. I'd rather go all
the way back to steamrolling the DOM with Backbone templates than these
pretend-semantical lumps of custom elements and attributes.

Sorry for ranting. I'm still sore about being burned by Angular.

~~~
thoman23
How exactly were you "burned by Angular"? Many of us here are using it very
successfully. And no, you don't need to "serialize your data into some kind of
string format" (at least in the sense that you would never flatten JS objects
into serialized strings in order to work with them). Scopes definitely take
some getting used to, but they are not magical.

------
robotnoises
> We've decoupled Angular 2's rendering from the DOM.

Does this mean they are using some sort of virtual dom a la React?

------
DavidPP
if I'm reading this correctly, they also planning to release a react native
competitor?

"Native mobile UI. We're enthusiastic about supporting the Web Platform in
mobile apps. At the same time, some teams want to deliver fully native UIs on
their iOS and Android mobile apps."

~~~
alexd16
Actually they will integrate with react native and native script. They talked
about it (and demo it) in the angularu conference:
[https://www.youtube.com/watch?v=aHGmj_fqPLE&feature=youtu.be...](https://www.youtube.com/watch?v=aHGmj_fqPLE&feature=youtu.be&t=819)

------
__luca
One of the biggest benefit of Angular is the vast amount of libraries built on
it, like bootstrap-ui and ui-grid to name a few, how can we switch to Angular
2 until the most adopted ones don't switch too? (real question)

~~~
vanadium
Depends on how brave you are, really.

While a lot of the development community will likely be tracking 2.0's
development and working to release libraries not long after 2.0 releases...2.0
is effectively a 1.0 release all over again, so it's a matter of production-
readiness not only where community support is concerned, but with itself.

I'm waiting to see where things shake out on all sides after a few releases
before really judging anything. We'll still kick the tires on our team here in
the meantime.

------
__luca
Commets here made me think about whether it's forward-looking using angular
1.0 for next projects: i guess i'll go with React with my short-coming project
then... I don't know what to do

~~~
collyw
In my limited experience React is way easier to comprehend than Angular.

~~~
help_everyone
I've had the opposite experience, with a code base responsible for millions in
revenue each month.

Took less than a day to understand angular from nothing -- taking more than a
day just to evaluate flux implementations with react.

------
oDot
Anyone knows how Angular 2 plays with "outside" code? It is very frustrating,
having to convert everything to a directive when using with Angular 1.

------
Bahamut
For the curious, this is the official repository for the ng2-to-ng1 engine:
[https://github.com/ngUpgraders/ng-forward](https://github.com/ngUpgraders/ng-
forward)

~~~
mikeryan52
ng-forward contributor here: that is not the ng2-to-ng1 engine. ng-forward is
an Angular team sanctioned library for eventually enabling Angular 2 syntax in
Angular 1. It shares a lot of goals with what is outlined in today's
announcement but is more catered for teams that want to start an app today
with the quickest possible migration strategy.

The code for the ng2-to-ng1 engine (called ng-upgrade) is either not public
yet or will be at
[https://github.com/angular/angular](https://github.com/angular/angular)

~~~
Bahamut
Ahh, I was mistaken with what I saw in the gitter then - thanks for correcting
me!

------
greenpizza13
This is really great news for my company, as we have several Angular 1
applications still in development that can benefit from this incremental
upgrade pattern.

------
help_everyone
Finally! There has been talk for what seems months for an upgrade path. I'm so
happy that there is finally some clarification.

------
crimsonalucard
The dramatic shift from version 1 to 2 is generally a sign of design mistakes.
Angular 1 should have been angular beta.

~~~
ahoge
Browsers and JavaScript have changed quite a bit since 2009. You couldn't have
created something like Angular 2 6 years ago or even 2 years ago for that
matter. Angular 2 is possible today thanks to technological advancements.

~~~
arcosdev
For example?

~~~
ahoge
For one, it's written in TypeScript. There is one codebase for ES5/6,
TypeScript, and Dart. A big benefit of Angular 2 is the better tooling you get
with TypeScript and Dart.

It uses things like classes, decorators, and the <template> tag. It uses a
virtual DOM, which is still a fairly new concept. It can run in Web Workers
and you can even use it for native applications which do not have a regular
DOM.

It really is quite different from anything one could have started back in
2009. Even those odd-looking attribute might have not worked because HTML5,
which specified a lot of those things more precisely, was far from being done.

Angular 1.x made pretty good use of the things which were available at the
time.

------
deckiedan
Slightly off topic, sorry, but I do HATE how blogger.com sites are totally
unusable with JS turned off / noscript / etc ...

~~~
muzmath
Welcome to the 0.01%

------
oompt
Aurelia is looking nice right now.

~~~
greenpizza13
Care to elaborate?

