Angular
Angular
Angular modules help us to organize the application. Every application will have at least one module
i.e. Root Angular module.
Modules:
In java script we have problems with namespace and there is no proper code organization.
Module will resolve this issue. Type script also having modules
ES 2015 Modules:
Angular Modules:
We can have multiple modules and atleast 1 module(i..e Root module) if there are extra features we
can put those in Feature module. If there are any shared module then we can put those things in
Shared Module. Each component we write is belongs to only 1 module.
Difference between ES Modules vs Angular Modules:
Components
First we define properties with type and the values. Property names usally follow
camelCase
Method will be define after the properties in a class body. Method names are verbs
Class is not enough to complete the component it also requires template i.e we need to
provide extra information and that can be done by metadata
A class becomes Angular component when we give the meta data. Angular needs this
meta data to know how to instantiate the component and construct the view and interact
with component.
Decorator : A function that adds meta data to class
We add these decorators above the class signature. Syntax similar to attributes in other
languages. Since decorator is a function we use ( ) and we pass Object to the Component
function with {} . Object will have many properties
If we want to use the component in any HTML we use “Selector” it defines the directive
name. When we use this directive Angular will render the that Particular component
Component should always have a template
Import statement: