Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of controller in Angular 2

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?

like image 699
Vladimir Melekh Avatar asked Oct 11 '16 19:10

Vladimir Melekh


People also ask

Does Angular 2 have controllers?

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.

What is the replacement of the controller and scope in Angular 2?

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.

Are there controllers in angular?

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.

Is $scope still supported in angular 2+?

In Angular 2, controllers and $scope were replaced by components and directives. Components are directives with a template.


1 Answers

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

like image 91
Joe Deluca Avatar answered Sep 28 '22 00:09

Joe Deluca