Components
AngularJS has controllers, scopes, and directives to deal with views, bind data, and respond to events by updating changes to data. In Angular, Components replaced controllers, scopes, and directives from AngularJS.
Angular, introduced components that support the object-oriented component model to write cleaner code. A component is a simple class that holds the logic of managing the associated template or view. A simple component class is given as follows:
Class FirstComponent { }
In a component class, we will expose properties and methods to a template or view. Component properties can provide data for a template or view and allow the user to modify property values. Component methods can be called according to user actions over the view.
The Angular component FirstComponent
As you can see, the preceding code creates a simple JavaScript class named
. You may be wondering how a JavaScript plain class can be treated as a component and how a template can be wired up to...FirstComponent