2017-07-25 142 views
2

我已经有了一个全新的Electron Forge安装与angular2模板。我碰到了角度依赖关系^4.3.1,zone.js^0.8.14并添加了hammerjspackage.json(使用Angular 4材质组件)。Electron Forge + Angular 4打破“匿名”不是一个已知元素

然后,我在src/app目录中添加了功能NG4应用程序的源代码。

当运行electron-forge start控制台输出是正确的,并且应用程序启动,但DevTools显示此错误:

Unhandled Promise rejection: Template parse errors: 
'anonymous' is not a known element: 
1. If 'anonymous' 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. ("tin\Desktop\ef-ng\node_modules\electron-compile\lib\protocol-hook.js:216:25) 
    at Generator.next ([ERROR ->]<anonymous>) 
    at step (C:\Users\Quentin\Desktop\ef-ng\node_modules\electron-compile\lib\protocol-h"): ng:///C:/Users/Quentin/Desktop/ef-ng/src/app/[email protected]:23 

这里是我的app.component.html的样子:

<app-main-toolbar></app-main-toolbar> 
<app-tree-item-tabs></app-tree-item-tabs> 
<app-search-view *ngIf="appState.searchIsVisible"></app-search-view> 
<app-media-view *ngIf="appState.activeMedia" [media]="appState.activeMedia"></app-media-view> 

如果我用这个代替它,那么它运行正常(但当然这不是我要找的):

<app-main-toolbar></app-main-toolbar> 
<app-tree-item-tabs></app-tree-item-tabs> 
<app-search-view></app-search-view> 

注意我删除了app-media-view组件和app-search-view组件上的*ngIf。我曾经使用一个把moduleId : module.id.split('\\').join('/'),添加到我的@Component声明中的技巧,但这在这里不起作用。

我真的被困在这里。

有什么想法? 谢谢!

编辑

这里是如何mediaapp-media-view定义:

get media(): Media { 
    return this._media; 
} 

@Input() 
set media(value: Media) { 
    this._media = value; 
    // More things 
} 

下面是如何appStateAppComponent定义:

constructor(
    protected bootstrap:BootstrapService, 
    public appState: AppStateService) {} 

回答

1

有可能是在您的组件应用中的一些错误引用-search-view或app-media-view。

您是否已在app-media-view组件中声明@Input() media: any;

appState是否在您的应用程序组件中声明?也许你可以尝试打印他们看看。

如果您在src/app目录中添加了功能NG4应用程序(不是电子伪造)的源代码,您需要更改所有导入以及对模板和样式的引用。 app不再是您的根文件夹。现在根文件夹是src。因此,例如,如果您有templateUrl: ./myTemplate.html,则必须更改为templateUrl: ./src/app/myTemplate.html

+0

刚刚在最近的编辑中回答了你的问题,我希望这有助于:) – Quentin

相关问题