Skip to content

Instantly share code, notes, and snippets.

@amimaro
Last active July 29, 2024 14:04
Show Gist options
  • Save amimaro/0bd7acf587325bddc83a75f650f7f046 to your computer and use it in GitHub Desktop.
Save amimaro/0bd7acf587325bddc83a75f650f7f046 to your computer and use it in GitHub Desktop.
Toggle Bulma Modal with Angular 5
Toggle Bulma Modal with Angular 5
<div class="modal" [ngClass]="{ 'is-active' : isModalActive }">
<div class="modal-background" (click)="toggleModal()"></div>
<div class="modal-card">
<header class="modal-card-head">
<p class="modal-card-title">Modal title</p>
<button class="delete" aria-label="close" (click)="toggleModal()"></button>
</header>
<section class="modal-card-body">
<!-- Content ... -->
</section>
<footer class="modal-card-foot">
<button class="button is-success">Save changes</button>
<button class="button" (click)="toggleModal()">Cancel</button>
</footer>
</div>
</div>
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-my-component',
templateUrl: './my-component.component.html',
styleUrls: ['./my-component.component.css']
})
export class MyComponent implements OnInit {
isModalActive: boolean = false;
constructor() { }
ngOnInit() {
}
toggleModal() {
this.isModalActive = !this.isModalActive;
}
}
@himanshurajora
Copy link

Thank You For This ... I was looking for a solution like this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment