https://angular.dev/guide/directives
Built-in
Note
You can
import { CommonModule } from '@angular/common';which imports the common directives; or import directly.
import {} from "@angular/common"| Common directives | Details | Import |
|---|---|---|
| NgClass | Adds and removes a set of CSS classes. | import { NgClass } from '@angular/common'; |
| NgStyle | Adds and removes a set of HTML styles. | import { NgStyle } from '@angular/common'; |
| NgModel | Adds two-way data binding to an HTML form element. | import { FormsModule } from '@angular/forms'; |
| NgIf | import { NgIf } from '@angular/common'; |
Creating
@Directive({
selector: "[appSelect]",
})
export class SelectDirective {
private templateRef = inject(TemplateRef)
private viewContainerRef = inject(ViewContainerRef)
}