So, i'm creating a custom directive and need to use form-controls into it. But i'm getteng an error: No provider for NgControl; I know that the right answer is: import reactive forms module but i've already imported !
import { Directive, ElementRef, Input, HostListener, OnDestroy } from '@angular/core';
import { NgControl } from '@angular/forms'
@Directive({
selector: '[testDirective]'
})
export class TestDirectiveClass implements OnDestroy{
constructor(private elementRef: ElementRef, c: NgControl ) { }
ngOnDestroy() {
}
}
my component:
<p testDirective>
Start editing to see some magic happen :)
</p>
and my appModule:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { TestDirectiveClass } from './testDirective.directive';
import { AppComponent } from './app.component';
import { HelloComponent } from './hello.component';
@NgModule({
imports: [ BrowserModule, FormsModule, ReactiveFormsModule ],
declarations: [ AppComponent, HelloComponent, TestDirectiveClass ],
bootstrap: [ AppComponent ]
})
export class AppModule { }