Component is a controller class with a template which deals with application and logic a view in a page. It is a bit of code which can be used throughout an application. Component knows how to render itself and configure dependency injection.
Component contains 2 important things, view and some logic.
Below example describes the use of component in Angular 2:
Above code includes below configuration options:
To run the code, TypeScript(.ts) files are needed which should be saved under the app folder.
Now create a component in TypeScript(.ts) file which creates a component and view for the component.
Running the above code, displays the text specified within the template option which is defined in the component_app.component.ts file and holds component's companion template that tells Angular how to render a view.
Below steps can be carried out to see how above code works:
OR this file can be run in another way:
Angular 2 Related Interview Questions
|PHP Interview Questions||Angular JS Interview Questions|
|Ext JS Interview Questions||Django Interview Questions|
|Java Abstraction Interview Questions||Angular Material Interview Questions|
|Phonegap Interview Questions||MongoDB Interview Questions|
|Angular 5 Interview Questions||Angular 4 Interview Questions|
|Angular 6 Interview Questions||Angular 7 Interview Questions|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.