Angular Junior interview questions and answers
75 questions for a Angular (Junior) interview - with correct answers, explanations and links to the docs.
Take this quiz- 1.What is Angular?
- 2.Which command creates a new Angular project?
- 3.What does the
@Componentdecorator describe? - 4.What does
standalonemean for an Angular component? - 5.How is a standalone Angular application started?
- 6.What does the default
ViewEncapsulation.Emulateddo with component styles? - 7.What does
:hostmean in a component's styles? - 8.Which language are Angular applications written in?
- 9.What does
{{ user.name }}do in a template? - 10.What is the difference between
src="{{ url }}"and[src]="url"? - 11.How do you handle a button click?
- 12.What does
(keyup.enter)="submit()"do? - 13.What is the "banana in a box" syntax
[(ngModel)]="name"? - 14.How do you toggle a CSS class depending on a condition?
- 15.What is a template reference variable
#nameInput? - 16.Why should template expressions be simple and free of side effects?
- 17.Which Angular feature makes
{{ user?.address?.city }}safe whenuserisnull? - 18.How do you conditionally render a block in modern Angular templates?
- 19.What is required in an
@forblock? - 20.What does the
@emptyblock do? - 21.Which block selects one of several templates by value?
- 22.What are pipes in Angular templates?
- 23.What does the
asyncpipe do? - 24.How do you create a custom pipe?
- 25.How does a child component receive data from its parent?
- 26.How does a child component notify its parent about an event?
- 27.Why can't a child change the value of a signal created by
input()? - 28.What is
<ng-content />used for? - 29.What is a service in Angular?
- 30.How do you get a service instance inside a component?
- 31.Where can
inject()be called? - 32.What does
providedIn: 'root'mean? - 33.Why is dependency injection useful for testing?
- 34.What is
ngOnInittypically used for? - 35.When is
ngOnDestroycalled? - 36.When does
ngOnChangesrun? - 37.What is a signal in Angular?
- 38.What is
computed()used for? - 39.Why is it wrong to mutate an array inside a signal like this?
- 40.What does
effect()do? - 41.How are routes configured in an Angular app?
- 42.Where does the router render the matched component?
- 43.How do you create a navigation link without a full page reload?
- 44.How do you navigate from code, for example after saving a form?
- 45.What are the two classic approaches to forms in Angular?
- 46.How do you connect a reactive form to the template?
- 47.How do you show a validation error only after the user has touched the field?
- 48.How do you make an HTTP GET request in Angular?
- 49.What is an Observable (RxJS)?
- 50.What does
pipe(map(...), filter(...))do on an Observable? - 51.Which command starts the local development server?
- 52.What does
ng generate component user-carddo? - 53.How do you declare an input that the parent must always provide?
- 54.What does
<ng-container>render in the DOM? - 55.Which variables are available inside an
@forblock? - 56.How do you set an inline style with a unit, e.g. width in pixels?
- 57.How do you highlight the menu link for the current route?
- 58.How do you show a "Page not found" component for unknown URLs?
- 59.How do you read the
:idparameter of the current route in a component? - 60.How do you set the browser tab title for a route?
- 61.Why doesn't
this.http.get('/api/users')send any request? - 62.What must be registered to inject
HttpClientin a standalone app? - 63.How do you format a date in a template?
- 64.What is
@letused for in a template? - 65.Where do you keep different API URLs for development and production builds?
- 66.How do you emit a value from a component declared with
output()? - 67.Why should a template call
user()rather thanuserwhenuseris a signal? - 68.How do you update a signal based on its current value?
- 69.What does
[disabled]="form.invalid"on a submit button do? - 70.Which validators make a field mandatory and check an email format?
- 71.What does
ng buildproduce by default in a new project? - 72.Which file is the entry point that bootstraps a standalone Angular app?
- 73.What does
RouterLinkwith an array do? - 74.How do you show a button only to admins and a label to everyone else?
- 75.What is TypeScript strict mode in an Angular project useful for?