Complete the code to declare a generic Angular service class.
export class DataService<[1]> { constructor() {} }
The generic type parameter is usually a single uppercase letter like T to represent a type.
Complete the method signature to return an Observable of the generic type.
getData(): Observable<[1]> {
// implementation
}The method should return an Observable of the generic type T to keep it flexible.
Fix the error in the generic method to accept a parameter of generic type and return it.
processData(data: [1]): [1] { return data; }
The parameter and return type should both use the generic type T to maintain consistency.
Fill both blanks to declare a generic method that returns an Observable of the generic type.
fetchItem<[1]>(id: number): Observable<[2]> { // implementation }
The method declares its own generic type U and returns an Observable of U.
Fill all three blanks to create a generic Angular service method that filters an array of generic items by a property value.
filterItems(items: [1][], key: keyof [2], value: any): [3][] { return items.filter(item => item[key] === value); }
any.All blanks use the generic type T to keep the method flexible and type-safe.