Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.3k views
in Technique[技术] by (71.8m points)

typescript - How can I remove reCaptchaV3 in Angular after changing pages via a router?

I need your help. Since I'm new to Angular I'm trying a lot to make a good page and learn something. To make my form submit a bit safer, I've used this lib here to include Google reCaptchaV3 into my page:

https://www.npmjs.com/package/ng-recaptcha#example-basic-v3

I've followed the tutorial and added everything to my main app.modules.ts:

imports     : [
  RecaptchaV3Module,
  RecaptchaModule,
],
providers   : [
  ValidateRecaptchaService,
  {provide: RECAPTCHA_V3_SITE_KEY, useValue: 'XXXXXXXXXXXXXXX-5qwbFT5pN'}
],

After that I've went into my contact component with my contact form and created the check and everything. I found out that when I import the service:

private recaptchaV3Service: ReCaptchaV3Service

... the badge appears automatically on my page. But now I'm getting a problem. When I leave the page, the badge is still there but it shouldn't. Why is it still there? I've tried killing it in ngOnDestroy but the service has no termination method or something like this.

I know that I can use CSS but I want to understand the problem and solve it the right way. Thanks for your help!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...