What type of data binding is used when you want to send data from a component's class to its template?
- Event binding
- Interpolation binding
- One-way data binding
- Two-way data binding
In Angular, Two-way data binding is used when you want to send data from a component's class to its template, allowing data to flow in both directions between the component and the template.
To test directives with dependencies, Angular provides the _______ class which allows you to inject dependencies and spy on their usage.
- ComponentFixture
- TestBed
- TestBedDependency
- TestBedStub
To test directives with dependencies, Angular provides the TestBed class, which allows you to configure testing modules and inject dependencies.
In NgRx, the _____ property of an action usually contains additional information or context.
- Action
- Meta
- Payload
- Type
In NgRx, the Meta property of an action usually contains additional information or context that can be helpful when processing the action.
In template-driven forms, form controls are automatically created by Angular using the _____.
- FormControlDirective
- FormsModule
- NgModel
- TemplateDirective
In template-driven forms, form controls are automatically created using the NgModel directive.
In Angular, the _____ class is used to create form controls in reactive forms.
- FormBuilder
- FormControl
- FormGroup
- ReactiveFormsModule
In Angular, the FormControl class is used to create form controls in reactive forms.
You are building an e-commerce application and want to ensure that product details are fully loaded before navigating to the product detail page. Which feature of Angular's router would you use to achieve this?
- Angular Lifecycle Hooks
- Route Guards
- Router Interceptors
- Router Resolvers
To ensure that product details are fully loaded before navigating, you can utilize Router Resolvers. A resolver can fetch data asynchronously before activating a route, ensuring that the data is available when the route is displayed.
To enable lazy loading in Angular, you need to use the _____ property in your routing configuration.
- enableLazyLoad
- lazyLoad
- loadChildren
- routeLazy
To enable lazy loading in Angular, you need to use the loadChildren property in your routing configuration to specify the module to load lazily.
What technique can be used to ensure that an observable is automatically unsubscribed from, even if it was not manually unsubscribed?
- Angular automatically unsubscribes all observables by default.
- Employing the finalize operator to ensure automatic unsubscription.
- Implementing a custom unsubscription handler function.
- Using the unsubscribe method in a subscription.
To ensure that an observable is automatically unsubscribed, you can use the finalize operator, which allows for automatic cleanup when the observable completes, errors, or is unsubscribed. It is a good practice to prevent memory leaks.
The _____ decorator is used to mark a class as available to be provided and injected as a dependency.
- @Component
- @Dependency
- @Injectable
- @Service
The @Injectable decorator is used to mark a class as available to be provided and injected as a dependency in Angular.
You have an Angular form where users can input an email address. You want to check in real-time whether the email address is already registered in your system. Which type of validation would be suitable for this?
- Async Validators that perform server-side checks.
- Built-in Validators like required and email.
- Custom Synchronous Validators with JavaScript functions.
- Pattern Validators with regular expressions.
To check in real-time whether an email address is already registered, you should use Async Validators that perform server-side checks, allowing you to query the server for existing email addresses.