Module 8 - Dependency and Services Flashcards

1
Q

Module 8 - Dependency and Services

Import

A

//In the .ts file

import { CardbuttonsService } from ‘../cardbuttons.service’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Module 8 - Dependency and Services

Configure

A

//In .ts file
constructor(private cardService: CardbuttonsService) {}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Module 8 - Dependency and Services

Use

A

//In the .ts file

like() {
this.cardService.likeCard();
}

//In the HTML file
(click)=”like(‘likebutton01’)”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Code the command that will create a new Angular service called yourloginnameQuizService

A

ng generate service yourloginnameQuizService

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the purpose of the @Injectable() decorator in Angular?

A

The @Injectable() decorator is used to mark a class as a service that can be injected into other components or services, allowing dependency injection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you inject a service into a component in Angular? Provide an example from the slides.

A

A service is injected by including it in the component’s constructor.
Example:
constructor(private cardService: CardbuttonsService) { }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly