Jul 30, 2017 · 1 min read
Hi Netanel,
one of our Gitter friend tried to use your `reCAPTCHA` directive and ask about the same problem `ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: ‘true’. Current value: ‘false’.`.
I looked around and it seems that that if a wrong `key` is passed in
<div nbRecaptcha key=”public key” formControlName=”captcha”></div>then the control is set invalid during one CD cycle … `ngAfterViewInit` from valid (true) to invalid (false).
ngAfterViewInit() {
this.control = this.injector.get(NgControl).control;
this.setValidators();
}I tried just a temporary solution with `setTimeout` and the error disappear so the problem should be really here.
ngAfterViewInit() {
this.control = this.injector.get(NgControl).control;
setTimeout(() => {
this.setValidators();
});
}