Miloš Lapiš
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();
});
}

    Miloš Lapiš

    Written by

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade