Custom Attribute Directive | Directives | Angular 12+

Поділитися
Вставка
  • Опубліковано 1 жов 2024
  • 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

  • @wiktorwachowski6291
    @wiktorwachowski6291 Рік тому +1

    Shouldnt it be used with ngAfterViewInit instead of ngOnInit?

  • @mohammedabdulaziz3658
    @mohammedabdulaziz3658 2 роки тому +4

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

  • @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.

  • @leninnani5222
    @leninnani5222 2 роки тому +1

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

    • @procademy
      @procademy  2 роки тому +1

      Thank you so much 😀

  • @maheshsirsat1811
    @maheshsirsat1811 Рік тому

    Done

  • @TheKidrock1988
    @TheKidrock1988 Рік тому

    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?

  • @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

  • @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??

  • @dshakya
    @dshakya 2 роки тому +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  2 роки тому +4

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

  • @mohiburrahman5639
    @mohiburrahman5639 Рік тому

    perfect!!

  • @lewispil3529
    @lewispil3529 Рік тому

    great video!

  • @tsvetanabogdanova2342
    @tsvetanabogdanova2342 2 роки тому

    You explain very well. Thank you.