【发布时间】:2016-12-30 17:11:07
【问题描述】:
我正在创建一个带有node.js 服务器的angular2 客户端应用程序。客户端应用程序似乎工作得很好,这意味着:
- 我的所有请求都得到了适当的响应。
- 应用程序按预期加载和工作。
但我在终端收到此错误:
Error: The selector "app" did not match any elements
at DomRenderer.selectRootElement (/home/mu-user/Projects/my-app/dist/server/index.js:27126:23)
at selectOrCreateRenderHostElement (/home/mu-user/Projects/my-app/dist/server/index.js:15687:32)
at AppView._View_AppComponent_Host0.createInternal (/AppModule/AppComponent/host.ngfactory.js:12:16)
at AppView.create (/home/mu-user/Projects/my-app/dist/server/index.js:50916:21)
at ComponentFactory.create (/home/mu-user/Projects/my-app/dist/server/index.js:36656:36)
at ApplicationRef_.bootstrap (/home/mu-user/Projects/my-app/dist/server/index.js:23313:40)
at /home/mu-user/Projects/my-app/dist/server/index.js:23222:89
at Array.forEach (native)
at Object.Call (/home/mu-user/Projects/my-app/node_modules/es6-shim/es6-shim.js:307:14)
at Array.forEach (/home/mu-user/Projects/my-app/node_modules/es6-shim/es6-shim.js:1313:17)
不会中断webpack 或http-server。
问题是我为什么要面对这个问题以及如何解决它?
【问题讨论】:
-
你能包含一些你的主要文件吗?像 index.html、引导文件、模块..
-
这很可能是某种与 ngModule 相关的问题,因为您的应用不了解主要组件。您需要向我们展示一些我们可以提供帮助的代码
-
@echonax 这个项目包含 50 多个组件,几乎不可能添加整个代码,但是恢复到较旧的提交以获得更简单的版本,我注意到错误消失了。所以也没有用。
-
@JoshuaOhana 我使用了一个较旧的提交来展示一个更简单的版本,我注意到它正在工作。这是发现你是对的关键。你认为这个错误是一种“未处理”还是它实际上是为了显示“找不到应用程序元素”?除非你说,否则我无法理解其含义