0

I have to create a modal for one of my website. I have implemented ngx-bootstrap modal for that. I have defined the component in my bootstrap. It is running perfectly but when I'm viewing the console it is showing error message as

The selector "app-subscription" did not match any elements

Below is the code snippet for subscription.component.ts

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() {
  }

}

and for the home.component.ts

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

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

As per the ngx-bootstrap documentation I have added that in my entryComponents. Code snippet for app.module.ts

bootstrap: [AppComponent, SubscriptionComponent]

Please suggest me a fix for that.

James Z
  • 12,209
  • 10
  • 24
  • 44
daemon
  • 113
  • 3
  • 14

1 Answers1

2

Make sure you have added the SubscriptionComponent in the entryComponents array of the module.

Sachin Gupta
  • 4,981
  • 3
  • 16
  • 32
  • Thanks! I have removed it from bootstrap and added it in entryComponents. It is working fine now. :-) – daemon Dec 31 '18 at 06:56
  • 1
    Happy to help, and welcome to Stack Overflow. If this answer or any other one solved your issue, please mark it as accepted. – Sachin Gupta Dec 31 '18 at 06:58