Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I open Modal by clicking a custom button angular

I’ve created a custom button in separated component this allows me to add this component(button) where I want.
for exemple this is the custom component button :
AddBtn.component.html:

<button nbButton status="primary" onclick="openModal()">Affect TPE</button>

AddBtn.component.ts

@Component({
  selector: "ngx-nb-list",
  templateUrl: "./nb-list.component.html",
  styleUrls: ["./nb-list.component.scss"],
})
export class NbListComponent implements OnInit {


  constructor(private dialogService: NbDialogService) {}


  ngOnInit() {
    
  }

  openModal() {
    this.dialogService.open(AddUsercComponent);
  }


}

I want to display the button in the main component like add the button in home , on click on it I want to show a modal
for those are curious : I’m working on ngx-admin, I’m not allowed to add button in cell so I have to do somthing like that

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You should use the proper click directive when calling a click function in angular. Your code should be like this:

<button nbButton status="primary" (click)="openModal()">Affect TPE</button>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading