Bird
0
0

Which of the following is the correct way to define a facade service in Angular?

easy📝 Syntax Q3 of 15
Angular - Advanced Patterns

Which of the following is the correct way to define a facade service in Angular?

export class MyFacadeService {}
Aexport function MyFacadeService() {}
B@Injectable({ providedIn: 'root' }) export class MyFacadeService {}
C@Component({ selector: 'app-facade' }) export class MyFacadeService {}
Dexport interface MyFacadeService {}
Step-by-Step Solution
Solution:
  1. Step 1: Identify Angular service declaration

    Angular services use @Injectable decorator with providedIn to register globally.
  2. Step 2: Check options for correct syntax

    Only @Injectable({ providedIn: 'root' }) export class MyFacadeService {} uses @Injectable with providedIn: 'root', correct for services.
  3. Final Answer:

    @Injectable({ providedIn: 'root' }) export class MyFacadeService {} -> Option B
  4. Quick Check:

    Facade service syntax = @Injectable with providedIn [OK]
Quick Trick: Use @Injectable({providedIn:'root'}) for services [OK]
Common Mistakes:
  • Using @Component decorator for services
  • Defining service as a function or interface
  • Omitting @Injectable decorator

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes