Giter Club home page Giter Club logo

Comments (5)

hozjanmarko avatar hozjanmarko commented on May 21, 2024 1

I was writimg this on a phone :p

from coreui-free-angular-admin-template.

hozjanmarko avatar hozjanmarko commented on May 21, 2024

Do it the angular way... Make a component for a modal
import { Component, ViewChild, Input, TemplateRef } from '@angular/core';
import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal';

@component({
selector: 'ngx-modal',
templateUrl: './ngx-modal.component.html',
styleUrls: ['./ngx-modal.component.scss']
})
export class NgxModalComponent {
@ViewChild('modal')
protected modal: TemplateRef;
public Title: string;
public Content: string;

protected Visible: Boolean = false;

protected Show(options: ngxModalOption, modalClass: string): BsModalRef {
this.Title = options.Title;
this.Content = options.Content;

this.Visible = true;
this.modalRef = this.modalService.show(this.modal, { class: modalClass });
return this.modalRef;

}

@input()
public ShowWarning(options: ngxModalOption): BsModalRef {
return this.Show(options, "modal-dialog modal-lg modal-warning");
}

@input()
public ShowSucess(options: ngxModalOption): BsModalRef {
return this.Show(options, "modal-dialog modal-lg modal-success");
}

@input()
public ShowDaneger(options: ngxModalOption): BsModalRef {
return this.Show(options, "modal-dialog modal-lg modal-danger");
}

@input()
public ShowInfo(options: ngxModalOption): BsModalRef {
return this.Show(options, "modal-dialog modal-lg modal-info");
}

@input()
public ShowPrimary(options: ngxModalOption): BsModalRef {
return this.Show(options, "modal-dialog modal-lg modal-primary");
}

@input()
public Close() {
if (this.Visible)
this.modalRef.hide();
}

modalRef: BsModalRef;

constructor(private modalService: BsModalService) { }
}

export interface ngxModalOption {
Title: string;
Content: string;
}
<ng-template #modal>

{{Title}}

×

{{Content}}

close

from coreui-free-angular-admin-template.

kamal0808 avatar kamal0808 commented on May 21, 2024

@hozjanmarko Is this code gonna generate modals or notification alerts?

from coreui-free-angular-admin-template.

hozjanmarko avatar hozjanmarko commented on May 21, 2024

Modals... If are looking for a notification service, you could use ng2-toasty, dont forget to add the css of the package to the styles sectio of angular cli json

from coreui-free-angular-admin-template.

kamal0808 avatar kamal0808 commented on May 21, 2024

Thanks, I'm going with https://github.com/scttcper/ngx-toastr.

from coreui-free-angular-admin-template.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.