0
0
Angularframework~5 mins

Importing dependencies directly in Angular - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does it mean to import dependencies directly in Angular?
It means bringing in specific functions, classes, or modules from external libraries or Angular packages right where you need them in your code, so you can use them easily.
Click to reveal answer
beginner
How do you import a component from Angular's core package?
You write: <code>import { Component } from '@angular/core';</code> This brings the Component decorator into your file.
Click to reveal answer
beginner
Why is it better to import only what you need instead of the whole library?
Importing only what you need keeps your app smaller and faster because it avoids loading extra code that you don't use.
Click to reveal answer
beginner
Show an example of importing a service directly in Angular.
Example: <code>import { HttpClient } from '@angular/common/http';</code> This lets you use HttpClient to make web requests.
Click to reveal answer
beginner
What happens if you forget to import a dependency you use in your Angular file?
Your code will give an error because Angular won't know what that function or class means without the import.
Click to reveal answer
How do you import the RouterModule from Angular's router package?
Aimport RouterModule from 'angular/router';
Bimport { RouterModule } from 'angular-core';
Cimport { RouterModule } from '@angular/router';
Dimport RouterModule from '@angular/core/router';
What is the benefit of importing dependencies directly in Angular?
AIt helps keep the app size smaller and faster.
BIt removes the need for modules.
CIt automatically fixes bugs.
DIt makes the app load slower.
Which of these is a correct import statement in Angular?
Aimport { Injectable } from '@angular/core';
Bimport Injectable from '@angular/core';
Cimport { Injectable } from 'angular/core';
Dimport Injectable from 'angular';
What error might you see if you forget to import a dependency?
ASyntaxError: Unexpected token
BReferenceError: X is not defined
CTypeError: Cannot read property
DNo error, code runs fine
Where should you place import statements in an Angular file?
AAnywhere in the file
BAt the bottom of the file
CInside functions
DAt the top of the file
Explain how to import a dependency directly in Angular and why it is important.
Think about how you bring tools into your workspace only when you need them.
You got /4 concepts.
    Describe what happens if you use a class or function in Angular without importing it first.
    Imagine trying to use a tool you never took out of the toolbox.
    You got /4 concepts.