Challenge your understanding of core Angular fundamentals such as components, configuration, data binding, services, and more. This easy-level quiz covers the must-know basics for interviews and hands-on work.
Can Angular applications be developed without using TypeScript?
Explanation: TypeScript is required because Angular relies on its features like decorators and type checking. JavaScript alone cannot handle these features. Using JavaScript for small projects is not supported, and decorators specifically need TypeScript.
How does an Angular application structure the building of a web page?
Explanation: Angular uses components to build the UI, with each managing a section of the page. Static HTML, single-file approaches, or relying solely on services do not represent Angular's design.
What is the primary purpose of the angular.json file in an Angular project?
Explanation: angular.json holds build configurations, determining the entry point and output settings. It does not manage databases, specifically configure CSS frameworks, or list installed npm packages.
What does the ngOnInit() lifecycle hook do in Angular?
Explanation: ngOnInit is used for running code when a component is initialized. It does not destroy components, directly update the DOM, or save state to storage.
Which of the following is NOT a type of data binding in Angular?
Explanation: Reference binding is not a data binding type in Angular. Interpolation, property binding, and two-way binding are all established Angular data binding techniques.
What is the main role of directives in Angular?
Explanation: Directives modify the DOM, such as hiding elements or changing classes. They do not manage builds, routing, or stylesheets.
Why are services and dependency injection important in Angular?
Explanation: Services contain reusable logic or data, and DI provides these to components. Rendering, styling, and routing are not handled solely by services and DI.
How does routing work in Angular applications?
Explanation: Routing uses URL paths to switch between different views in Angular. The other options are unrelated to routing.
What is the recommended way to pass data from a parent component to a child component in Angular?
Explanation: @Input() allows the parent to pass values to the child. Constructors and direct DOM manipulation are not suitable for such data flow, and @Output() is for sending data up.
What is the main difference between ngIf, ngFor, and ngSwitch in Angular?
Explanation: ngIf, ngFor, and ngSwitch are structural directives with distinct functions on DOM elements. The incorrect options suggest unrelated behaviors or technical inaccuracies.