Complete the code to define a standalone Angular feature module.
import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FeatureComponent } from './feature.component'; @NgModule({ declarations: [FeatureComponent], imports: [[1]], exports: [FeatureComponent] }) export class FeatureModule {}
The CommonModule provides common directives like ngIf and ngFor needed in feature modules.
Complete the code to import the feature module into the root module.
import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { AppComponent } from './app.component'; import { FeatureModule } from './feature/feature.module'; @NgModule({ declarations: [AppComponent], imports: [BrowserModule, [1]], bootstrap: [AppComponent] }) export class AppModule {}
The root module imports the feature module to include its components and functionality in the app.
Fix the error in the feature module by completing the code to declare the component.
import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { [1] } from './feature.component'; @NgModule({ declarations: [FeatureComponent], imports: [CommonModule], exports: [FeatureComponent] }) export class FeatureModule {}
The component class FeatureComponent must be imported to declare it in the module.
Fill both blanks to create a feature module with a service provider.
import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FeatureComponent } from './feature.component'; import { [1] } from './feature.service'; @NgModule({ declarations: [FeatureComponent], imports: [CommonModule], providers: [[2]], exports: [FeatureComponent] }) export class FeatureModule {}
The service class FeatureService must be imported and added to the providers array to be injectable within the module.
Fill all three blanks to create a feature module with a component, service, and import.
import { NgModule } from '@angular/core'; import { [1] } from '@angular/common'; import { [2] } from './feature.component'; import { [3] } from './feature.service'; @NgModule({ declarations: [FeatureComponent], imports: [CommonModule], providers: [FeatureService], exports: [FeatureComponent] }) export class FeatureModule {}
Import CommonModule for common directives, FeatureComponent to declare the component, and FeatureService to provide the service.