【发布时间】:2019-04-02 15:53:15
【问题描述】:
tl;博士 尝试将 google 课堂分享按钮添加到我的网络应用程序(angular 5,spa)时,我收到以下错误:
Uncaught Error: Template parse errors:
':g:sharetoclassroom' is not a known element:
1. If ':g:sharetoclassroom' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
</div>
<div class="qr-code">
[ERROR ->]<g:sharetoclassroom url="..." size="32"></g:sharetoclassroom>
</div>
</div>
"): ng:///AppModule/ShareLinkComponent.html@18:8
我想将google classroom share button 添加到我的网络应用程序中,但我不知道为什么无法识别共享按钮元素。
我已将脚本 (<script src="https://apis.google.com/js/platform.js" async defer></script>) 添加到 index.html 中的 <head> 中。我已将分享按钮元素添加到其中一个组件中:
<!-- share-link.component.html -->
<mat-dialog-content>
<div i18n class="share-link-text">
Share the assessment link with your students.
</div>
<div class="share-container">
<div class="share-to-classroom">
<g:sharetoclassroom url="http://url-to-share" size="32"></g:sharetoclassroom>
</div>
</div>
</mat-dialog-content>
但是当我在本地运行代码时,我收到了错误':g:sharetoclassroom' is not a known element。我真的不明白发生了什么/缺少什么。
奇怪的是,当我将元素添加到 index.html(不在任何其他组件中)时,共享按钮实际上会出现并按预期工作。
任何人都知道加载第 3 方脚本/使用 gapi/使用不需要(看似)需要添加到 AppModule 中的第 3 方元素的任何问题?
我尝试将脚本直接放在组件中,将 NO_ERRORS_SCHEMA 添加到 @NgModule.schemas (这抑制了错误,但按钮根本没有出现,尺寸为 0x0...)。我没有创意,但会补充说我不是一个角度专家......
【问题讨论】:
标签: html angular google-classroom