Angular 2 architecture consists of module , component , template , metadat , data binding , service , directive and dependency injection.Some of them are :
- Module
- Component
- Template
- Metadata
Module:
A module is a block of code that is used to perform a single task. We can build our application using these modules. Component class can be exported from a module. We can use the export statement to export the component class from the module.
export class TestComponent { }
The export statement tells us that this is a module and its TestComponent class is defined as public and it can be accessible by other modules of the application.
Component:
A Component is a basic building block for angularJS application.It is simply "a part of the web page" .
Template:
This tells the angular how to display the component.
<div>
The name is : {{name}}
</div>
We put the template expression inside the interpolation braces to display it is value.
Metadata:
It is a way of processing a class.Suppose we have a component name TestComponent which will be treated as a class until we tell the Angular that it is a component. For this purpose, we can use metadata to tell the angular that TestComponent is a component. Metadata is attached to typescript using the decorator.
@Component({
selector : 'testlist',
template : '<h2>Name is Rahul</h2>'
directives : [TestComponent]
})
export class TestComponent{ }
0 Comment(s)