I created an structural directive. Here is the constructor of that class.
constructor(private templateRef: TemplateRef<any>, private viewContainer: ViewContainerRef, public query: NgModel) {
console.log(this.query)
}
If I remove public query:NgModel
, it works fine. If I add it It throws error.
Error: Uncaught (in promise): No provider for NgModel! (ControlMeta -> NgModel)
What is the error here?
I did same for normal directive, it is working fine.
You have to specify NgModel
as provider
:
@Directive({
selector: '...',
providers: [NgModel],
...
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With