I'm trying to update existing angular 1 application to angular 2. I'm confused, there is nothing about controllers. What is the easiest way to migrate controllers to Angular 2?
With Angular 2, the essence of the controller still exists, but it has evolved into a more sophisticated life form known as the component class.
The controllers and $scope in Angular 1 have been replaced with “Components” in Angular 2. Hence we can say that it is a component-based framework, which uses zone.
AngularJS applications are controlled by controllers. The ng-controller directive defines the application controller. A controller is a JavaScript Object, created by a standard JavaScript object constructor.
In Angular 2, controllers and $scope were replaced by components and directives. Components are directives with a template.
Angular2 is built from the ground up. Your best solution is to use Angular2 "Components".
Read more about Components at https://angular.io/api/core/Component
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With