【发布时间】:2017-08-11 01:32:22
【问题描述】:
我按照这个教程http://ej2.syncfusion.com/angular/documentation/grid/getting-started.html
我将SyncFusionModule 设置为 Angular 模块,以导出我计划在BenchmarkModule 中使用的所有“Syncfusion EJ 2 for Angular”组件。 GridComponent 在
@syncfusion/ej2-ng-grids/src/grid/index 可以被 Angular 拾取;因此,它被认为是一个 Angular 组件。但是,datasouce 没有在“GridComponent”中声明,而是在其父 Grid 中声明,这不是 Angular 组件,而是在 @syncfusion\ej2-grids 中声明的标准组件。似乎我错过了某个地方的依赖项导入,以帮助 Angular 找到 Grid 的定义。但我不确定如何解决这个问题。
一开始我以为是因为我跳过了http://ej2.syncfusion.com/angular/documentation/grid/getting-started.html#configuring-system-js中描述的SystemJS映射;因此,我提出了这个问题Webpack solution for SystemJS mapping。但是其中一个答案表明我可能不是原因。
这里是 GitHub 存储库 https://github.com/lamLeX/IocPerformance/tree/gh-pages/IocPerformanceResultWebApp/src/app,以防有人想知道文件的结构以帮助我解决依赖关系,因为我在 JS 依赖关系解决方面没有太多经验;尤其是 ES6 模块解析。
从答案更新: 故障代码取自此示例 http://ej2.syncfusion.com/angular/demos/#/grid/grouping,我已将示例代码中的错误通知 SyncFusion 团队。
<div class="control-section">
<ej-grid height="320" [datasource]="data" [groupsettings]="groupOptions" [allowgrouping]="true" allowsorting="true" allowpaging="true">
<e-columns>
<e-column field="Inventor" width="180" headertext="Inventor Name"></e-column>
<e-column field="NumberofPatentFamilies" width="220" textalign="right" headertext="Number of Patent Families"></e-column>
<e-column field="Country" width="140" headertext="Country"></e-column>
<e-column field="Active" width="120"></e-column>
<e-column field="Mainfieldsofinvention" width="200" headertext="Main fields of invention"></e-column>
</e-columns>
</ej-grid>
<div style="margin-top: 10px; text-align: right">Source:
<a href="https://en.wikipedia.org/wiki/List_of_prolific_inventors" target="_blank">Wikipedia: List of Prolific inventors</a>
</div>
</div>
【问题讨论】:
-
这里的 GridModule 不是
imported 在模块 github.com/lamLeX/IocPerformance/blob/gh-pages/… 中。我想这就是问题所在。对于非 Angular 组件,可能还有其他选项,但对于 Angular 组件,当缺少组件声明时会发生此错误。 -
我尝试添加 import { Grid } from '@syncfusion/ej2-grids';在发布问题之前,但仍然出现错误
-
并在
@NgModule中添加 Grid 以导入数组只会产生另一个错误,说Unexpected value 'Grid' imported by the module 'SyncFusionModule'. Please add a @NgModule annotation. -
是的,编译器会为您进行调试。应该是
import { GridModule } from '@syncfusion/ej2-grids'和imports: [GridModule]。这应该适合你。 -
@syncfusion/ej2-grids中没有GridModule。Grid在@syncfusion/ej2-grids中,GridComponent在@syncfusion/ej2-ng-grids中。GridModule是一个 Angular 模块,它在其declarations和exports数组中声明和导出GridComponent。我尝试按照您的建议使用 `import { Grid} from '@syncfusion/ej2-grids';` 在我的SyncFusionModule中导入 Grid,但 JIT 仍然无法找到 Grid 的属性
标签: javascript angular ecmascript-6 syncfusion es6-modules