HI im使用Angular 6和ng-boostrap我添加了一个模态 调用FocusComponent,我需要将其添加到entryComponents,因此我将ConfirmAutoFocusComponent添加到app.module.ts中,如下所示:
bootstrap: [AppComponent, ConfirmAutoFocusComponent]
它可以工作,但是在F12控制台上弹出错误
ERROR Error: The selector "app-confirm-auto-focus" did not match any elements
at DefaultDomRenderer2.push../node_modules/@angular/platform-browser/fesm5/platform-browser.js.DefaultDomRenderer2.selectRootElement (platform-browser.js:1068)
at DebugRenderer2.push../node_modules/@angular/core/fesm5/core.js.DebugRenderer2.selectRootElement (core.js:11449)
at createElement (core.js:8129)
at createViewNodes (core.js:10360)
at createRootView (core.js:10313)
at callWithDebugContext (core.js:11344)
at Object.debugCreateRootView [as createRootView] (core.js:10831)
at ComponentFactory_.push../node_modules/@angular/core/fesm5/core.js.ComponentFactory_.create (core.js:8659)
at ComponentFactoryBoundToModule.push../node_modules/@angular/core/fesm5/core.js.ComponentFactoryBoundToModule.create (core.js:3311)
at ApplicationRef.push../node_modules/@angular/core/fesm5/core.js.ApplicationRef.bootstrap (core.js:4540)
我看到了有关此问题的其他帖子,但是它的作用似乎很有效
答案 0 :(得分:1)
更多@ user184994和@CruelEngine 将其添加到app.module.ts中
bootstrap: [AppComponent], entryComponents: [ConfirmAutoFocusComponent]
解决了问题