Summary
Let’s recap what we learned about attribute directives in the form of a short summary.
By this point, we’ve learned a lot about attribute directives, including how to create custom ones. In this lesson, we’ll recap and summarize everything we learned about attribute directives.
Generate a file
To generate a file using Angular CLI, we use the following command:
ng generate directive app-avatar
Directive syntax
An empty directive class looks like this:
@Directive({
selector: '[appAvatar]'
})
export class AvatarDirective {
constructor() { }
}
Apply the directive
To use the directive, we need to apply it to a specific element in the Angular template, like this:
...