Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

upgrade angular 1 to 2

I have my angular app with version 1 so can i upgrade it with angular version 2

We started to design a new project that designated to be built with Angular as each of our previous, the importance of this project is very high and it's going to live and maintained for at least years.

Angular 2.0 has came in beta mode and it seems like everything is about to change, $scope is out, directives are out and the whole DI concept is about to change.

  1. Is there a migration path/strategy to be considered in the next few months?
  2. If we built the project using 1.x, what action do we need to take during development to ensure a clean migration? Are those 2 versions can be considered as 2 different framework?

Please help me to sort out.

like image 558
user2515556 Avatar asked Jan 14 '16 09:01

user2515556


People also ask

How do I upgrade to the latest version of Angular?

Updating Angular CLI to the latest version is pretty much simple if you are using Angular 9 or 10 version above. Just update @angular/core and @angular/cli by using ng update command. If you are using Angular material You have to update it as well using ng update command.

Is Angular 2 backwards compatible?

Since Angular 2 is not backward compatible, all existing apps built in Angular 1. x are required to be migrated to version 2 because the Angular team will now be focusing more support on latest versions and previous ones will have less and less support in the future.

How do I upgrade my Angular project?

Updating angular-cli To update angular-cli to a new version, you must update both the global package and your project's local package. Running ng init will check for changes in all the auto-generated files created by ng new and allow you to update yours.

How do I upgrade from Angular 7 to Angular 12?

Run ng update @angular/core@12 @angular/cli@12 which should bring you to version 12 of Angular. Angular now requires TypeScript 4.2. ng update will update you automatically.


1 Answers

I think that migrating from Angular 1 to 2 is not nearly as bad as most people think it is.

Basically, you need to break it down and migrate the concepts first...

  • Bootstrapping
  • Controllers
  • Directives
  • Components
  • Modules
  • Routing
  • Services
  • Forms
  • Filters

Almost all of those can be mapped back to 1.x concepts - even if there is not a 1:1 relationship. Once you understand how each of these things are done, it's much easier to decide how to slowly migrate your existing code to the new concepts.

It's hard to cover each and all of those things in a single SO answer, so maybe check out ngmigrate.telerik.com which goes into a lot more detail.

like image 183
Burke Holland Avatar answered Oct 14 '22 17:10

Burke Holland