Categories
All Categories
DMV
ServSafe
OSHA
NCLEX
HESI
TEAS
ATI Nursing
CNA & Nurse Aide
NREMT & EMS
ACLS
BLS
CPR
Quizzes
Study Guides
Flashcards
Packages
0
Log In
Register
Categories
All Categories
DMV
ServSafe
OSHA
NCLEX
HESI
TEAS
Quizzes
Study Guides
Flashcards
Packages
Contact
Cart
0
Log In
Register
Angular Interview Practice
Access More Questions
Report question problem
×
I think the answer is wrong
There are multiple correct answers
There is a typing error
Image or comprehension text is not display properly
Something else(please specify below)
Any more information
Which decorator is used to create a custom directive in Angular?
@Component
@Injectable
@Directive
@NgModule
Reveal Answer
Correct Answer:
@Directive
Explanation:
The use of the @Directive decorator is essential in Angular for creating custom directives. Directives are a powerful feature in Angular that allow you to extend the capabilities of HTML elements by attaching behavior to them. When you define a directive with the @Directive decorator, it enables the directive to manage elements in the DOM. This includes controlling their appearance, behavior, or transforming them based on certain conditions. The decorator allows you to specify the selector that determines when the directive should be applied, as well as any metadata required for the directive’s functionality. In contrast, other decorators serve different purposes within Angular. The @Component decorator is specifically for creating components, which are the building blocks of an Angular application that encompass both the view and behavior. The @Injectable decorator is used for services, marking them as available for dependency injection. The @NgModule decorator is used to define a module that encapsulates components, directives, services, and other code related to a specific application feature, but it is not used for creating directives themselves. Thus, using @Directive is the correct way to create a custom directive, allowing developers to enhance and customize the behavior of elements within their Angular applications.
Access more questions from this quiz
Continue to Angular Interview Practice for more practice questions and the full quiz experience.
Access More Questions