In Angular, which module is primarily responsible for enabling routing functionality?

  • NgModule
  • Router
  • RouterModule
  • RoutingModule
In Angular, the primary module responsible for enabling routing functionality is RouterModule. This module provides the necessary directives and services to set up and configure routing within an Angular application. NgModule is a foundational module used for structuring Angular applications, and RoutingModule is not a standard Angular module.

The ngOnInit method is a part of the ________ lifecycle hook in Angular.

  • Component
  • Directive
  • Module
  • Service
The ngOnInit method is a part of the "Component" lifecycle hook in Angular. This hook is called after Angular has initialized all data-bound properties but before rendering the view. Developers commonly use ngOnInit to perform initialization tasks for a component, such as fetching initial data or setting up subscriptions. Understanding Angular's lifecycle hooks is crucial for effective component development.

The [()] syntax in Angular is commonly referred to as ________ binding.

  • Bi-directional
  • Double
  • Twin
  • Two-way
The [()] syntax in Angular is commonly referred to as "Two-way" binding. It allows data to flow in both directions between a component's template and its class, enabling real-time synchronization. This is a key feature in Angular that simplifies data binding and user input handling, enhancing the interactivity of Angular applications.

In template-driven forms, the ______ directive is used to group controls and aggregate their values and validation status.

  • FormGroupDirective
  • NgModelGroupDirective
  • FormControlDirective
  • FormsModuleDirective
In template-driven forms in Angular, the NgModelGroupDirective is used to group controls and aggregate their values and validation status. This directive allows you to manage the behavior and validation of a group of form controls within a form. The other options are not used for this purpose in template-driven forms.

How can a child component emit an event to inform its parent component about a particular action?

  • By calling a predefined Angular function, emitEvent(), from the child component.
  • By modifying the parent component's properties directly from the child component.
  • By using @Output and emitting an event from the child component, which the parent component can listen to.
  • By using Angular services to communicate between the child and parent components.
A child component can emit an event to inform its parent component by using @Output and emitting an event that the parent component can subscribe to. Directly modifying the parent component's properties from the child component is not a recommended practice. Calling a predefined function like emitEvent() is not a standard Angular approach. Using services can facilitate communication between components but is not the direct way for a child to inform its parent about an action.

To listen for changes on a form control, you can subscribe to its ______ observable.

  • statusChangesObservable
  • valueChangesObservable
  • errorsObservable
  • formChangesObservable
In reactive forms, you can listen for changes on a form control by subscribing to its "valueChanges" observable. This allows you to track changes in the value of the form control over time. The other options do not represent the correct observables to listen for changes on a form control in reactive forms.

For configuring proxies during development to bypass CORS issues, you'd modify the ______ file in an Angular CLI project.

  • app.module.ts
  • environment.prod.ts
  • proxy.conf.json
  • tsconfig.json
To configure proxies for handling CORS issues during development in an Angular CLI project, you would modify the proxy.conf.json file. This file allows you to define proxy rules for routing requests to different backend servers, helping you bypass CORS restrictions.

In the Angular router, what is the purpose of the pathMatch property?

  • It defines a regex pattern for matching route paths.
  • It defines the route's path as an exact match.
  • It determines the order in which routes are evaluated.
  • It specifies the default route when no other route matches.
The 'pathMatch' property in Angular router configurations is used to define how the router should match the URL path. When set to 'full', it requires an exact match of the path segment, ensuring that the URL path must match the route path entirely for the route to activate. This is useful for defining routes with empty path or catch-all routes.

What is the primary command to create a new Angular application using Angular CLI?

  • ng create
  • ng generate
  • ng init
  • ng new
The primary command to create a new Angular application using Angular CLI is ng new. This command initializes a new Angular project with default settings, including the necessary files and folder structure.

Which header is crucial for making a CORS request to a different domain using HttpClient?

  • 'Access-Control-Allow-Origin'
  • 'Authorization'
  • 'Content-Type'
  • 'User-Agent'
The 'Access-Control-Allow-Origin' header is crucial for enabling Cross-Origin Resource Sharing (CORS) when making requests to a different domain. It specifies which origins are permitted to access the requested resource, allowing for secure cross-domain communication.