Angular Interview Questions Part 1

1. What is the default port when you create new project in Angular?
Ans : 4200

2. How to change default port using commands?
Ans.  ng serve --host --port 5200

3. When a new module or service or component is created, its references are updated in which file?
Ans. app.module.ts

4. How to provide path separator for router in Angular?
Ans. Generally, the standard separator used is slash('/'). 
We need to add the below line of code before header tags in index.html page.
<base href="/">

5. In which part of the file, template is included?

Ans. By using @View, we can include template in a file.
Example :  @View ({ template : "<h1>hello</h1>" })

6. What does export keyword specify if we use it before app component ?
Ans. When we use export keyword it make app component "public" that means we can use the app component in other modules
in the application.

7. How to create component using command line?
Ans. A component is nothing but like view in angular. There are two ways to create components.
1. Either creating manually 
2. ng g c componentname

8. In Agular "OnInit" is interface or class ?
Ans.  Its an interface from core library.

9. What module is required to use HttpClient in services?
Ans. One has to import HttpClientModule in AppModule to use HttpClient.

10. What HttpClient returns generally?
Ans. It returns Observable. One has to subscribe to observable to get the http response data.

Recent Posts


Receive Quality Tutorials Straight in your Inbox by submitting your Email below:

Delivered by FeedBurner

Protected by Copyscape Duplicate Content Checker