Angular – Forms & Routes – Fresco Play
Dependency Injection:
In Angular, dependencies are defined as Services which will be injected into those objects which ask for it.
Service/Dependencies are always defined inside “constructor” of the class
Provider:
It is a meta- data that generates instance of services that the injector injects into components and other services.
Service:
Schema
Services is a class that has a specific purpose. Services are mainly used to provide data to components that ask for it.
Components use Services, fetches data and generates view.
Assessment Dependency Injection Answer:
1.Which of the following provides data to components?
A. Decorators
B. Pipes
C. Attributes
D. Services
Answer: Services.
2. You define Services in __________.
A. Component
B. Decorator
C. Class
D. Constructor
Answer: Constructor
3. Which of the following creates new services requires by the applications?
A. Providers
B. Component
C. Dependency Injection
D. Injectable
Answer: Providers
Routers:
Router in angular defines route to navigate from one view to another, as user performs task on the application.
Routers are used to develop Single Page Applications.
Traditionally websites used to load the whole webpage, on clicking any of the links. This increases page load time, bandwidth consumption affecting user experience.
Now you can just load the required view, instead of sending the request to server to send a whole new webpage.
Assessment Routers Answer:
1.Which of the following is affected/changed on loading components?
A. Attribute Directive
B. URL
C. Observable
D. Structural directive
Answer: URL
2.Which mechanism allows the user to navigate between components/views?
A. HTTP request
B. Routing
C. Dependency Injection
D. Services
Answer: Routing
3.Router defines mapping of URL to _________.
A. Component
B. Pipes
C. HTML page
D. Directive
Answer: Component
4.Which property of Routes defines the path of the components?
A. href
B. src
C. path
D. url
Answer: path
5.The following or router guard types, except _________.
A. CanDeactivateChild
B. CanDeactivate
C. CanActiveChild
D. CanActive
Answer: CanDeactivateChild
Forms:
There are 2 types of forms in angular:
- Template Driven Forms (TDD)
- Reactive (or Model Driven) Forms
Assessment Forms Answer:
1.You can prevent Angular 2 from auto- validating the form by using _________.
A. form.novalidate
B. validate=”manual”
C. validate=”disabled”
D. novalidate
Answer: novalidate
2.Form groups can nest inside other FormGroups.
A. True
B. False
Answer: True
3. Which of the following will be true if the user changed the value of control?
A. Pristine
B. Valid
C. Dirty
D. Touched
Answer: Dirty
Final Assessment Answer:
1.________ decorator creates services.
A. @decorator.
B. @services
C. @injectable
D. @output
Answer: @injectable
2.which of the following will be true if the user changed the value of control?
A. touched
B. dirty
C. Pristine
D. Valid
Answer: dirty
3.Which decorator is optional if the class has any other decorator?
A. @component
B. @Input
C. @injectable
D. @output
Answer: @injectable
4.You add novalidate attribute to a form to prevent the browser from automatically validating.
A. false
B. True
Answer: True
5.Which function bootstraps the form to it’s pristine state?
A. ngSubmit
B. next
C. reset
D. bootstrap
Answer: reset
6. Router defines mapping of URL to __________.
A. Directive
B. Pipe
C. HTML page
D. Component
Answer: Component
7.You place ________ where you want the components to be inserted.
A. None of the options
B. router- inlet
C. router- insert
D. router- outlet
Answer: router- outlet
8. The following or router gaurd types, except ___________.
A. CanActivate
B. CanDeactivate
C. CanDeactivateChild
D. CanActiveChild
Answer: CanDeactivateChild
9.Which of the following creates new services required by the applications?
A. Dependency Injection
B. Component
C. Provider
D. Injectable
Answer: Provider
10.An observable can handle multiple events.
A. False
B. True
Answer: True
11.In an Http call, from where is the data fetched?
A. API
B. Service
C. @Input
D. Component
Answer: API
12.Which property of Routes defines the path of the component?
A. url
B. path
C. href
D. src
Answer: path
13. ___________ is not a primary HTTP verb.
A. FETCH
B. PATCH
C. GET
D. POST
Answer: FETCH
14. In reactive forms, the HTML of the form is automatically created.
A. True
B. False
Answer: False.
15.FormsModule is imported from @angular/________ in Model Driven Form
A. form
B. core
C. forms
D. None of the options
Answer: forms
16. The following are operators of observables, except ________.
A. reduce
B. filter
C. geo
D. map
Answer: geo
17. Non-parameterised routes always take priority over parameterized routes.
A. False
B. True
Answer: True
18. ________ act as a container to store all the services required for creating a component.
A. registrable
B. injectable
C. imports
D. providers
Answer: providers
19. Which property describes the path you want to redirect the user?
A. src
B. redirectTo
C. None of the options
D. href
Answer: redirectTo
20 . @Service decorator is used to create a new service.
A. False
B. True
Answer: False
Disclaimer: The main motive to provide this solution is to help and support those who are unable to do these courses due to facing some issue and having a little bit lack of knowledge. All of the material and information contained on this website is for knowledge and education purposes only.