The imports property is component metadata for declaring dependencies available to a standalone component. It replaces NgModule-based dependency lookup by keeping required modules, components, directives, and pipes beside the component. section 1.3.3 section 2.3.1
Older Angular components commonly received dependencies through NgModules. Standalone components instead import what their templates use directly, reducing broad imports such as CommonModule when a single directive is sufficient. section 1.3.3 section 2.3.1
Use the property to:
- Import an NgModule such as FormsModule when the template uses ngModel. section 2.3.1
- Import standalone directives such as NgIf instead of importing all of CommonModule. section 2.3.1
- List standalone components, directives, and pipes required by the component template. section 1.3.3
Login form with focused imports
A standalone LoginComponent can declare imports: [FormsModule, NgIf]. FormsModule enables [(ngModel)] for email and password fields, while NgIf enables the validation message shown when either credential is missing. The component can still use an NgModule dependency and a standalone directive together. section 2.3.1
Listing 2.7 Standalone component importing a module
@Component({
selector: 'app-login',
template: `
<div class="login-container">
<h1>Login</h1>
<form>
<input type="text" name="email"
placeholder="Email"
[(ngModel)]="credentials.email" /> #1
<input type="password" name="password" placeholder="Password"
[(ngModel)]="credentials.password">
<button type="submit">Login</button>
</form>
</div>
`,
standalone: true,
imports: [FormsModule], #2
})
export class LoginComponent {
credentials = { email: '', password: '' };
}
Inspect a complete standalone component using FormsModule through its imports property and binding form fields with ngModel. section 2.3.1
For migration, author new declarations as standalone, convert existing components individually, move their NgModule declaration into imports, preserve exports where needed, and remove modules incrementally as build errors are resolved. section 2.5.1

