0
0
Angularframework~5 mins

Why directives are needed in Angular - Quick Recap

Choose your learning style9 modes available
Recall & Review
beginner
What is the main purpose of directives in Angular?
Directives let you add behavior to HTML elements, making your app interactive and dynamic without changing the element's core structure.
Click to reveal answer
beginner
How do directives help in reusing code in Angular?
Directives allow you to package common behaviors and apply them to many elements, so you write code once and reuse it everywhere.
Click to reveal answer
intermediate
What types of directives exist in Angular and why are they important?
Angular has three types: components (with templates), attribute directives (change appearance/behavior), and structural directives (change layout). Each type helps manage UI in a clear way.
Click to reveal answer
intermediate
Why can't we just use plain HTML and JavaScript instead of Angular directives?
Directives provide a clean, organized way to add behavior that fits Angular's reactive model, making apps easier to build, maintain, and test compared to mixing plain HTML and JS.
Click to reveal answer
intermediate
How do directives improve the separation of concerns in Angular apps?
Directives separate UI behavior from layout and data logic, so each part of the app has a clear role, making the code easier to understand and update.
Click to reveal answer
What is a key reason Angular uses directives?
ATo create database connections
BTo replace CSS styling
CTo write server-side code
DTo add custom behavior to HTML elements
Which directive type changes the layout by adding or removing elements?
AAttribute directive
BStructural directive
CComponent directive
DService directive
Why are directives better than plain JavaScript for UI behavior in Angular?
AThey integrate with Angular's reactive system and improve maintainability
BThey are slower but easier to write
CThey replace HTML completely
DThey only work on server side
Which of these is NOT a type of Angular directive?
AComponent directive
BAttribute directive
CDatabase directive
DStructural directive
How do directives help with code reuse?
ABy packaging behavior to apply on many elements
BBy duplicating code in many places
CBy removing all JavaScript
DBy forcing inline styles
Explain why Angular directives are needed and how they improve building web apps.
Think about how directives make HTML elements smarter and easier to manage.
You got /4 concepts.
    Describe the different types of Angular directives and their roles.
    Focus on what each directive type controls in the UI.
    You got /3 concepts.