Course Content

Course Content

FAQs

  • Make a class using the @Directive attribute.
  • Assign the attribute directive name to the @Directive decorator's selector metadata.
  •  Change the appearance and behaviour of the host element by using the ElementRef class to access the DOM.

To make a custom directive, we must use the @Directive decorator instead of the @Component decorator. So, let's begin by making our first Custom Attribute directive. We'll use this directive to highlight the specified DOM element by changing its background colour. Create a highlight for your app.

  • Component is a template-based directive.
  • Structural directives - controls DOM elements, allowing us to add and delete items from the document. For example, *ngIf, *ngFor, and so on.
  • Attribute directives - to change an element's, component's, or directive's behaviour or appearance.

An element's class attribute defines one or more classnames. The class attribute is typically used to point to a style sheet class. It can, however, be utilised by JavaScript to make changes to HTML components with a defined class (through the HTML DOM).

A class attribute for an element defines one or more classnames. The class attribute is most commonly used to refer to a style sheet's class. It can, however, be used by JavaScript to modify HTML components with a defined class (through the HTML DOM).

Recommended Courses

Share With Friend

Have a friend to whom you would want to share this course?

Download LearnVern App

App Preview Image
App QR Code Image
Code Scan or Download the app
Google Play Store
Apple App Store
598K+ Downloads
App Download Section Circle 1
4.57 Avg. Ratings
App Download Section Circle 2
15K+ Reviews
App Download Section Circle 3
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere