When creating a custom pipe, implementing the _____ interface ensures that the pipe recalculates only when the input values change.
- DynamicPipe
- OnChanges
- PipeTransform
- PipeUpdate
When creating a custom pipe in Angular, implementing the PipeTransform interface ensures that the pipe recalculates only when the input values change.
You have an Observable stream of user actions in your application. You want to perform a side effect, such as logging, each time an action occurs without modifying the original stream. Which RxJS operator should you use?
- do (or tap)
- filter
- map
- take
When you want to perform side effects on an observable stream without modifying the data, you should use the do (or tap) operator. This allows you to perform actions like logging or debugging without altering the original stream.
What is the main benefit of using child routes in Angular applications?
- Creating shared services
- Handling HTTP requests
- Lazy loading components
- Navigating to the parent
The main benefit of using child routes in Angular is lazy loading components, which improves performance by loading components on demand.
The Ivy Renderer in Angular optimizes the application by using _____ rendering.
- Asynchronous
- Client-side
- Server-side
- Synchronous
The Ivy Renderer in Angular optimizes the application by using Asynchronous rendering to improve performance.
What is the purpose of the fixture in Angular testing?
- To create a component
- To define routing
- To set up a testing module
- To simulate user interactions
The fixture in Angular testing is used to simulate user interactions and provides access to the component's DOM for testing.
To create a custom directive that modifies the structure of the DOM, you would use a _____ directive.
- attribute
- component
- service
- structural
To modify the structure of the DOM, you would use a structural directive in Angular, such as ngFor or ngIf.
In Angular, using the _____ pipe can automatically handle subscription and unsubscription, preventing memory leaks.
- Async
- Observer
- Promise
- Subscribe
In Angular, using the Async pipe can automatically handle subscription and unsubscription, preventing memory leaks by managing the observable's lifecycle for you.
The router-outlet directive acts as a _____ where the routed component is displayed.
- Container
- Directive
- Placeholder
- Router hub
The router-outlet directive acts as a placeholder where the routed component is displayed in Angular routing.
When creating a Route Resolver, it must implement the _____ interface.
- Resolve interface
- ResolveInterceptor
- Resolveable
- RouterResolver
When creating a Route Resolver, it must implement the Resolve interface. The Resolve interface defines a method to retrieve data for a route before it is activated.
You have an Angular service that makes HTTP requests. During testing, you want to ensure that your service handles errors correctly. Which tool or technique would you use to simulate an HTTP error response?
- Angular HttpClient Mocking
- Angular TestBed
- Jasmine Spies
- Protractor End-to-End Testing
To simulate an HTTP error response during testing, you can use Angular HttpClient Mocking, which allows you to control HTTP responses in tests.
Imagine you have a directive that applies accessibility enhancements to elements. How would you test that the directive is correctly applying the necessary ARIA roles and attributes?
- Manually inspect HTML
- Use a screen reader
- Use end-to-end tests
- Use linters
To test the accessibility directive, you should manually inspect the generated HTML to ensure that it correctly applies the necessary ARIA roles and attributes. End-to-end tests may also help validate this behavior.
How do you create a custom pipe in Angular?
- By creating a service
- By defining a TypeScript function
- By extending the Pipe class
- By using Angular directives
To create a custom pipe in Angular, you define a TypeScript function decorated with the @Pipe decorator. This function transforms the input data as needed.