Basic Angular Knowledge Review (Mega Quiz)
This lesson contains all of the recap quizzes from all of the lessons in this module. I have added headers to each group of quizzes so that you know which lesson to go back and study if you get stuck. Good luck!
TypeScript and ES6 Concepts
Which of the following best describes TypeScript...
TypeScript does not actually change anything about the existing JavaScript syntax, it just adds new features to it
Correct!
Incorrect
What ES6 concept is used to help display/bind values and events to an Angular component's template?
Correct!
Incorrect
Incorrect
Which best describes the role of a promise?
Incorrect
Incorrect
Correct!
Structure of an Angular application
What best describes the typical role of the root component?
Incorrect.
Incorrect. It is @NgModule's that provide a compilation context
Correct!
What is required in order to use the app-root tag in our index.html file?
Incorrect. It is the root module that must be supplied to bootstrapModule
Correct!
The only way to display a component is to configure a route for it with the RouterModule
Incorrect
Correct! We can also add components directly to the template of another component
An Introduction to Angular Template Syntax
The best syntax for binding a variable to a property is...
Nice!
Although this will work in some cases, the interpolation syntax will convert whatever you are trying to bind to a string, which may not be desired. It is safer to use the square bracket syntax.
If we want to bind a click event to some method we would do...
Incorrect
Correct!
Incorrect
If we wanted to render out the result of 1 + 1 in the template, which of the following would work?
Incorrect
Incorrect
Correct!
What is the correct way to set up two way data binding?
Incorrect. This will only achieve one way data binding.
Correct!
Incorrect
What is the correct way to set up a template variable?
Correct!
Incorrect
Incorrect
Select the component that a directive with a selector of [myDirective] would apply to
Incorrect
Correct!
Incorrect
The *ngIf structural directive will...
Correct!
Incorrect
Incorrect
The *ngFor structural directive will...
Incorrect
Correct!
Incorrect
Understanding Decorators in Angular
A decorator could be best described as a way to...
Incorrect
Correct!
Incorrect
One role of the @Component decorator is to...
Incorrect
Correct!
Incorrect
Which of these best describe the role of a directive...
Incorrect
Incorrect
Correct!
A pipe allows us to...
Incorrect
Incorrect
Correct!
Working with Components in Angular
An @Input() allows...
Correct!
Incorrect. Technically, it is possible to pass in something like a FormControl as an input, and then use that to send data back to the parent. But, typically, inputs are not used for communicating with the parent component.
The proper syntax for setting up an input is...
Incorrect
Correct!
Incorrect
How can you use data from a child component in a parent component?
Correct!
This is kind of correct, but not typically the best approach in this situation. For parent/child relationships you generally want to use inputs and outputs. Using a shared service is better suited to situations where components do not have a parent/child relationship
Incorrect. This is technically possible, but not typically required.
NgModules, Routing, and Standalone Components
If we want to make a component available to use within a module we can...
Incorrect. We can not import a component directly into a module (unless we are using standalone components), we could only import a module that declares that component
Correct!
Incorrect
Which of the following contains an exhaustive list of all declarables (i.e. they can be added to the declarations array of a module)?
Incorrect
Incorrect
Correct!
What best describes what happens when we import one module into another module?
Incorrect
Incorrect
Correct!
Which is the best description of the SCAM approach?
Correct!
Incorrect
Incorrect
Why would we export something from a module?
Incorrect
Correct!
Incorrect. They are still useable within the module that declares them.
Understanding Dependency Injection in Angular
What is the correct way to inject MyService?
Incorrect
Correct!
Incorrect
Which of the following is NOT a benefit of dependency injection?
Incorrect. This is a benefit of DI.
Incorrect. This is a benefit of DI.
Correct! Although we often use DI to share a single instance of a dependency, we can create multiple instances as well if we want.
What is the best way to configure sharing a single instance of a dependency with the entire application
Correct!
Incorrect. This will still work, but it is better to use the providedIn property in most cases
Incorrect
Change Detection: OnPush vs Default
What are the three main ways change detection can be triggered with the OnPush strategy?
Correct!
Incorrect. If the input to a component is mutated it will have the same reference, and change detection will not be triggered
Incorrect. These are all things that would only trigger change detection with the Default strategy
If a component has an object as an input, what do you need to do to make sure changing the values in that object triggers change detection with the OnPush strategy?
Incorrect. Mutating an existing object means the input will maintain the same reference, and will not trigger change detection.
Correct!
How should we update the propertyToOverwrite value of an object if we are using the OnPush strategy?
Correct!
Incorrect
Incorrect. Investigate how the "spread" syntax works for objects in JavaScript
Navigating and Passing Data Between Pages
What is the correct way to navigate to another route in Angular from the template?
Incorrect. This is how you would typically link with HTML, but in Angular this will cause the page to reload which is not ideal.
Correct!
Incorrect
What is the correct way to navigate to another route in Angular from the class?
Correct!
Incorrect
Incorrect
If we want a route to accept a parameter called 'word' on a route called 'define' how would we set that up?
Incorrect
Incorrect
Correct!
If we wanted to get access to the 'word' param on our 'define' page what should we inject into our component?
Correct!
Incorrect
Incorrect
User Input and Forms in Angular
What are the two form modules we can import from Angular?
Incorrect
Correct!
Incorrect
The three main types of form controls we can create are...
Correct!
Incorrect
Incorrect
What is the correct way to make a field required using FormBuilder?
Incorrect
Incorrect
Correct!
What property of a form group can we use to check if all the validators have passed?
Incorrect
Correct!
Incorrect
What event can we bind to on a form element to handle a submission?
Correct!
Incorrect
Incorrect
Fetching Data from a Backend/API
What needs to be injected in order to make an HTTP request?
Incorrect
Correct!
Incorrect. This is required to be imported in the root module, but it does not need to be injected in the component
What is the correct syntax for making an HTTP request?
Incorrect
Incorrect
Correct!
Congratulations!
Nice work completing this module! You can go back and study if you got any of these questions wrong if you like, but it isn’t necessary to continue. You aren’t going to absorb everything all at once, so feel free to continue on to the next module and come back again later if you need.