Skip to content

Instantly share code, notes, and snippets.

@forfrossen
forfrossen / confirm-modal-and-service.ts
Created October 11, 2018 10:37 — forked from jnizet/confirm-modal-and-service.ts
How to create a reusable service allowing to open a confirmation modal from anywhere with ng-bootstrap
import { Component, Injectable, Directive, TemplateRef } from '@angular/core';
import { NgbModal, NgbModalRef, NgbModalOptions } from '@ng-bootstrap/ng-bootstrap';
/**
* Options passed when opening a confirmation modal
*/
interface ConfirmOptions {
/**
* The title of the confirmation modal
*/
@forfrossen
forfrossen / confirm-module.ts
Created October 2, 2018 07:22 — forked from whisher/confirm-module.ts
How to create a reusable service allowing to open a confirmation modal to use with canDeactivate using ng-bootstrap
/*
Credit to: https://gist.github.com/jnizet/15c7a0ab4188c9ce6c79ca9840c71c4e
Credit to: Giuseppe Luca Lo Re
*/
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Injectable } from '@angular/core';
import { CanDeactivate } from '@angular/router';