Top 10 Angular 5 Interview Questions And Answers
Angular 5 newest version released in October 2017.While Angular used to be the go-to solution for front-end web development, it has encountered competition over the past few years. following are Top 10 Angular 5 Interview Questions And Answers.
1). What’s new in Angular 5?
Ans : – Following are the new features available in angular 5.
- Angular 5 supports Typescript version 2.4
- Angular 5 supports RxJS 5.5 which has new features like Pipeable Operators
- A build tool to make the js bundles (files) lighter Ahead of Time (AOT) is updated to be on by default
- Events like ActivationStart and ActivationEnd are introduced in Router
2). Explain component life cycle in Angular?
Ans :- In Angular component life cycle in Angular goes through following
- Create and render children
- Check for bound data changes and re-render
3). What is the difference between observable and promises?
Ans : – The differences between observable and promises are:-
|It is not lazy||By default, it is Lazy as it emits values when time progresses|
|Observable can be canceled.The two possible decisions are as below.
Use unsubscribe() method for this.
|Promises can not be canceled.|
|It provides the map, forEach, filter, reduce, retry and retryWhen operators.||Promise does not provide any operators.|
|Emits a single value only||Emits multiple values|
4). What are the differences between Component and Directive?
Ans : –
- for registering a component always use @Component meta-data annotation.
- Component is used to break up the application into smaller components.
- Component is used to break up the application into smaller components
- @View decorator or templateurl template are mandatory in the component.
- For registering directives,always use @Directive meta-data annotation
- Directive is used to add behavior to an existing DOM element
- Directive is use to design re-usable components.
- Directive don’t have View.
5). List the types of Data Binding supported by Angular5?
- Ans : – Angular 5 supports four types of Data Binding They are
- String Interpolation
- Property Binding
- Event Binding
6). What is ViewEncapsulation?
Ans : – View encapsulation give the definition whether the template and styles defined within the component can affect the whole application or vice versa.
6). Explain the difference between JIT Compiler and AOT Compiler in Angular ?
Ans : –
- JIT compiles at run-time but AOT compiles our at build time.
- JIT Compiles before running but AOT Compiles while running
- JIT and Aot both are Highly secure
- JIT Very suitable for local development but Very suitable for production builds
7). What is the proper lifecycle hooks for the application development in Angular 5?
Answer: Following are the list of proper lifecycle of angualr 5.
8).Explain with example @Input and @Output in Angular 5?
Ans :- @Input(alias): here alias is the component name which needs binding.
Same like @Output (alias).
9). Explain the differences between Activated Route and Router Route in Angular 5?
Ans : – Activated route proving details information of the route which associated with the component loaded in an outlet, Router state represents only the state.
10). What are the advantages with AOT?
Ans :- Following are the list of AOT.
- Fast download:
- asynchronous requests
- Quicker rendering
- Reduces Http Requests
- Catches errors during the build phase
- It provides better security
for reference : Angualr Tutorials