【问题标题】:The selector "app-subscription" did not match any elements选择器“app-subscription”不匹配任何元素
【发布时间】:2018-12-31 19:42:57
【问题描述】:

我必须为我的一个网站创建一个模式。我已经为此实现了 ngx-bootstrap 模式。 我已经在我的引导程序中定义了组件。它运行完美,但是当我查看控制台时,它显示错误消息为

选择器“app-subscription”没有匹配任何元素

下面是subscription.component.ts的代码sn-p

export class SubscriptionComponent implements OnInit {
  closeBtnName: string;
  public email_id;
  subscribed:Boolean= false;
  showsubscribe: Boolean = true;
  public emailFormControl = new FormControl('', [ Validators.required, Validators.pattern(EMAIL_REGEX)]);

  constructor( public bsModalRef: BsModalRef, private 
  submit_service: 
    SubmitService, private modalService: BsModalService) { }

   ngOnInit() {
  }

}

对于 home.component.ts

if(this.router.url.includes('subscribe')){

  this.bsModalRef = this.modalService.show(SubscriptionComponent)
  this.bsModalRef.content.closeBtnName  = 'Close'
}

根据 ngx-bootstrap 文档,我已将其添加到我的 entryComponents 中。 app.module.ts 的代码 sn-p

bootstrap: [AppComponent, SubscriptionComponent]

请建议我解决这个问题。

【问题讨论】:

    标签: angular ngx-bootstrap-modal


    【解决方案1】:

    确保您已将SubscriptionComponent 添加到模块的entryComponents 数组中。

    【讨论】:

    • 谢谢!我已将其从引导程序中删除并将其添加到 entryComponents。现在工作正常。 :-)
    • 很高兴为您提供帮助,欢迎来到 Stack Overflow。如果此答案或任何其他答案解决了您的问题,请将其标记为已接受。
    猜你喜欢
    • 2016-06-09
    • 2016-06-09
    • 2016-11-24
    • 2018-09-23
    • 2020-03-06
    • 1970-01-01
    • 1970-01-01
    • 2021-05-13
    • 2020-05-26
    相关资源
    最近更新 更多