Custom Attribute Directive | Directives | Angular 12+

Поделиться
HTML-код
  • Опубликовано: 7 фев 2025
  • In this lecture, you will learn how to create a Custom attribute directive in Angular. The Angular directives help us to extend or manipulate the DOM. We can change the appearance, behavior, or layout of a DOM element using the directives.
    We already learned about Angular's built-in directives like ngIf, ngFor, ngStyle and ngClass in previous lectures of this course. In this lecture, we will create an attribute directive like ngStyle and ngClass.
    Let's learn how to create an attribute directive with an example.

Комментарии • 16

  • @mohammedabdulaziz3658
    @mohammedabdulaziz3658 3 года назад +4

    Start to end, it's awesome & very informatic about private variable name & selectors...👏

  • @leninnani5222
    @leninnani5222 3 года назад +1

    After getting 1k subs, you will get 10k within short time, all the best.

    • @procademy
      @procademy  3 года назад +1

      Thank you so much 😀

  • @wiktorwachowski6291
    @wiktorwachowski6291 Год назад +1

    Shouldnt it be used with ngAfterViewInit instead of ngOnInit?

  • @lewispil3529
    @lewispil3529 2 года назад

    great video!

  • @tsvetanabogdanova2342
    @tsvetanabogdanova2342 2 года назад

    You explain very well. Thank you.

  • @eyassh6747
    @eyassh6747 2 года назад

    hey sir, first of all great video secondly I have a question
    Can I make that same attribute directive take the color as a value?? if so then how??

  • @TheKidrock1988
    @TheKidrock1988 2 года назад

    I have a question. Why i have to create Directives , is it more simple if i use *ngClass and take some class form my css ot scss file .In which case more like i have to use this private Directives?

  • @mohiburrahman5639
    @mohiburrahman5639 2 года назад

    perfect!!

  • @narenderkonka9001
    @narenderkonka9001 2 года назад +2

    this.element = element is also not required in the constructor?

    • @chilhoankwon9073
      @chilhoankwon9073 Год назад

      1. First, Constructor gets called for the class instantiation. So, parameter element receives the value from the calling component.
      2.In side of Constructor, Received parameter value should be assigned to the defined local variable (this.element). this means current class.

  • @dshakya
    @dshakya 3 года назад +1

    This is helpful. Are you planning a series on Reactive forms? Just asking as I would like to see how you approach custom validation using custom attribute so that we do not have to add error templates in every single control. Can't get my head around it. I have seen it done but hard to understand. Thanks.

    • @procademy
      @procademy  3 года назад +4

      Hi Deepak. Yes. I will cover form handing and reactive forms in angular in detail in coming lectures.

  • @srikanthm2790
    @srikanthm2790 2 года назад

    I have a small doubt on this. When we use this custom directive in concern html file angular automatically detects the element and it is being captured in the constructor internally right!! Or am I thinking in that way

  • @maheshsirsat1811
    @maheshsirsat1811 Год назад

    Done