Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upgrade AngularJS 1.6 to Angular 5

I have read Angular's official document for upgrading from 1.x to version 5. But I unable to achieve ngUpgrade.

Can anybody help to resolve this issue or help me how to proceed?

Old Project is in AngularJS 1.6 and I am using ui-router for routing mechanism.

Below is the sample code for the of the controller,

heroController:

myApp.controller("heroController", ["$scope", function ($scope) {
    // Controller Code
}]);

index.cshtml code:

<body ng-app="myApp">
   <div ui-view></div>
</body>

I have a wrapper of MVC for existing application. Now I want to migrate to newer version of Angular(Version 5 and upcoming versions). Since the existing application have a lot of controllers, directives, services factories, thus I want to first ngUpgrade thereafter I will start migrating component wise.

NOTE: I am not using any build tools to bundle js files, I am using MVC's bundle.

like image 922
Ankur Avatar asked Oct 17 '25 16:10

Ankur


1 Answers

Two ways you can do,

(i) Best way is to rewrite the application.

(ii)Or migrate each module wise. You can read on How to migrate from the following blog.

https://vsavkin.com/migrating-angular-1-applications-to-angular-2-in-5-simple-steps-40621800a25b

like image 122
Sajeetharan Avatar answered Oct 20 '25 06:10

Sajeetharan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!