我正在开发Angular 2+ TypeScript应用程序。如果表单无效,我需要重置reCaptcha。但是在我的typescript代码中,当我编写grecaptcha.reset();时,我得到错误:Can not resolve symbol 'grecaptcha'
如何在何处重置reCaptcha或解析/声明grecaptcha变量?
我有一个Angular 2组件,我想通过元素的id来检索元素div <div id ="myId">。我尝试在我的组件(TypeScript)中执行:document.getElementById("myId"),但得到一个错误:“无法找到名称文档”。我在其他帖子中看到我们可以使用@ViewChild做类似的事情,但是我不知道如何使用div,有什么想法吗?
我有一个指令,它应该在输入框中修剪一个值。该指令在表单中修改了值,但当我提交它时,该值不会被修饰。
// this code works and the value is trimmed after submitting the form
<input type="text" matInput formControlName="adress" oninput="this.value = this.value.trim()">
// this code trim the value on the form but NOT after